PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.17
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.17
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.17, at app/Modules/Form/Inputs.php

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