PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.7
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.7
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / Form / Fields.php

Fields.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.7, at app/Services/Form/Fields.php

104 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Services\Form;
4
5 use FluentForm\App\Models\Form;
6 use FluentForm\Framework\Support\Arr;
7 use FluentForm\App\Modules\Form\FormFieldsParser;
8
9 class Fields
10 {
11 public function get($formId)
12 {
13 $form = Form::find($formId);
14
15 $fields = FormFieldsParser::getShortCodeInputs($form, [
16 'admin_label', 'attributes', 'options', 'raw'
17 ]);
18
19 $fields = array_filter($fields, function ($field) {
20 return in_array($field['element'], $this->supportedConditionalFields());
21 });
22
23 return $this->filterEditorFields($fields);
24 }
25
26 public function supportedConditionalFields()
27 {
28 $supportedConditionalFields = [
29 'input_hidden',
30 'address',
31 'input_name',
32 'select',
33 'ratings',
34 'net_promoter',
35 'textarea',
36 'shortcode',
37 'input_url',
38 'input_text',
39 'input_date',
40 'input_email',
41 'input_radio',
42 'input_number',
43 'select_country',
44 'input_checkbox',
45 'input_password',
46 'terms_and_condition',
47 'gdpr_agreement',
48 'phone',
49 'rangeslider',
50 'net_promoter_score',
51 'post_title',
52 'post_content',
53 'post_excerpt',
54 'taxonomy',
55 'input_image',
56 'input_file',
57 'chained_select',
58 'payment_method',
59 'custom_payment_component',
60 'multi_payment_component',
61 'item_quantity_component',
62 'cpt_selection',
63 'dynamic_field',
64 'subscription_payment_component',
65 ];
66
67 $supportedConditionalFields = apply_filters_deprecated(
68 'fluentform_supported_conditional_fields',
69 [
70 $supportedConditionalFields
71 ],
72 FLUENTFORM_FRAMEWORK_UPGRADE,
73 'fluentform/supported_conditional_fields',
74 'Use fluentform/supported_conditional_fields instead of fluentform_supported_conditional_fields.'
75 );
76 return apply_filters('fluentform/supported_conditional_fields', $supportedConditionalFields);
77 }
78
79 public function filterEditorFields($fields)
80 {
81 foreach ($fields as &$field) {
82 $element = Arr::get($field, 'element');
83 if ('select_country' == $element) {
84 $field['options'] = getFluentFormCountryList();
85 } elseif ('gdpr_agreement' == $element || 'terms_and_condition' == $element) {
86 $field['options'] = ['on' => 'Checked'];
87 } elseif ('quiz_score' == $element) {
88 $notPersonalityType = Arr::get($field, 'raw.settings.result_type') != 'personality';
89 if ($notPersonalityType && Arr::exists($field, 'options')) {
90 Arr::forget($field, 'options');
91 }
92 } elseif ('dynamic_field' == $element) {
93 $attrType = Arr::get($field, 'raw.attributes.type');
94 if ('text' == $attrType) {
95 Arr::forget($field, 'options');
96 }
97 }
98 Arr::forget($field, 'raw');
99 }
100
101 return apply_filters('fluentform/filtered_editor_fields', $fields);
102 }
103 }
104