PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.6
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.6
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 3.6.66 All 195 releases
fluentform / app / Modules / Form / Inputs.php

Inputs.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 4.3.6, at app/Modules/Form/Inputs.php

91 lines 2.4 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\Modules\Form;
4
5 use FluentForm\App;
6 use FluentForm\App\Modules\Acl\Acl;
7 use FluentForm\Framework\Foundation\Application;
8 use FluentForm\App\Services\FormBuilder\EditorShortcode;
9 use FluentForm\Framework\Helpers\ArrayHelper;
10
11 class Inputs
12 {
13 /**
14 * @var \FluentForm\Framework\Request\Request
15 */
16 private $request;
17
18 /**
19 * Build the class instance
20 * @throws \Exception
21 */
22 public function __construct(Application $application)
23 {
24 $this->request = $application->request;
25 }
26
27 /**
28 * Get all the flatten form inputs for shortcode generation.
29 */
30 public function index()
31 {
32 $formId = $this->request->get('formId');
33
34 $form = wpFluent()->table('fluentform_forms')->find($formId);
35
36 $fields = FormFieldsParser::getShortCodeInputs($form, [
37 'admin_label', 'attributes', 'options'
38 ]);
39
40 $fields = array_filter($fields, function ($field) {
41 return in_array($field['element'], $this->supportedConditionalFields());
42 });
43
44 wp_send_json($this->filterEditorFields($fields), 200);
45 }
46
47 public function supportedConditionalFields()
48 {
49 $supportedConditionalFields = [
50 'select',
51 'ratings',
52 'net_promoter',
53 'textarea',
54 'shortcode',
55 'input_url',
56 'input_text',
57 'input_date',
58 'input_email',
59 'input_radio',
60 'input_number',
61 'select_country',
62 'input_checkbox',
63 'input_password',
64 'terms_and_condition',
65 'gdpr_agreement',
66 'input_hidden',
67 'input_file',
68 'input_image',
69 'subscription_payment_component'
70 ];
71
72 return apply_filters('fluentform_supported_conditional_fields', $supportedConditionalFields);
73 }
74
75 public function filterEditorFields($fields)
76 {
77 foreach ($fields as $index => $field) {
78 $element = ArrayHelper::get($field, 'element');
79 if($element == 'select_country') {
80 $fields[$index]['options'] = App::load(
81 App::appPath('Services/FormBuilder/CountryNames.php')
82 );
83 } else if($element == 'gdpr-agreement' || $element == 'terms_and_condition') {
84 $fields[$index]['options'] = array('on' => 'Checked');
85 }
86 }
87
88 return $fields;
89 }
90 }
91