PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.14
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
← All changes | app/Services/FormBuilder/Components/Name.php +64 -18 3.6.656.2.14 View file →
@@ -3,27 +3,41 @@
3 3 namespace FluentForm\App\Services\FormBuilder\Components;
4 4
5 5 use FluentForm\App\Helpers\Helper;
6 6 use FluentForm\Framework\Helpers\ArrayHelper;
7 +use FluentForm\App\Services\FormBuilder\Components\Select;
7 8
8 -class Name extends BaseComponent
9 +class Name extends Select
9 10 {
10 11 /**
11 12 * Compile and echo the html element
12 - * @param array $data [element data]
13 - * @param stdClass $form [Form Object]
14 - * @return viod
13 + *
14 + * @param array $data [element data]
15 + * @param \stdClass $form [Form Object]
16 + *
17 + * @return void
15 18 */
16 19 public function compile($data, $form)
17 20 {
18 21 $elementName = $data['element'];
19 22
20 - $data = apply_filters('fluenform_rendering_field_data_'.$elementName, $data, $form);
23 + $data = apply_filters_deprecated(
24 + 'fluentform_rendering_field_data_' . $elementName,
25 + [
26 + $data,
27 + $form
28 + ],
29 + FLUENTFORM_FRAMEWORK_UPGRADE,
30 + 'fluentform/rendering_field_data_' . $elementName,
31 + 'Use fluentform/rendering_field_data_' . $elementName . ' instead of fluentform_rendering_field_data_' . $elementName
32 + );
21 33
34 + $data = apply_filters('fluentform/rendering_field_data_' . $elementName, $data, $form);
35 +
22 36 $rootName = $data['attributes']['name'];
23 37
24 38 $hasConditions = $this->hasConditions($data) ? 'has-conditions ' : '';
25 -
39 +
26 40 if (empty($data['attributes']['class'])) {
27 41 $data['attributes']['class'] = '';
28 42 }
29 43
@@ -28,23 +42,23 @@
28 42 }
29 43
30 44 $data['attributes']['class'] .= $hasConditions;
31 45 $data['attributes']['class'] .= ' ff-field_container ff-name-field-wrapper';
32 - if($containerClass = ArrayHelper::get($data, 'settings.container_class')) {
33 - $data['attributes']['class'] .= ' '.$containerClass;
46 + if ($containerClass = ArrayHelper::get($data, 'settings.container_class')) {
47 + $data['attributes']['class'] .= ' ' . $containerClass;
34 48 }
35 49 $atts = $this->buildAttributes(
36 50 ArrayHelper::except($data['attributes'], 'name')
37 51 );
38 52
39 - $html = "<div {$atts}>";
53 + $html = "<div {$atts}>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $atts is escaped before being passed in.
40 54 $html .= "<div class='ff-t-container'>";
41 55
42 56 $labelPlacement = ArrayHelper::get($data, 'settings.label_placement');
43 57 $labelPlacementClass = '';
44 -
58 +
45 59 if ($labelPlacement) {
46 - $labelPlacementClass = ' ff-el-form-'.$labelPlacement;
60 + $labelPlacementClass = ' ff-el-form-' . $labelPlacement;
47 61 }
48 62
49 63 foreach ($data['fields'] as $field) {
50 64 if ($field['settings']['visible']) {
@@ -54,24 +68,56 @@
54 68 'ff-el-form-control ' .
55 69 $field['attributes']['class']
56 70 );
57 71
58 - if ($tabIndex = \FluentForm\App\Helpers\Helper::getNextTabIndex()) {
72 + if ($tabIndex = Helper::getNextTabIndex()) {
59 73 $field['attributes']['tabindex'] = $tabIndex;
60 74 }
61 75
62 -
63 76 @$field['settings']['container_class'] .= $labelPlacementClass;
64 77
65 78 $field['attributes']['id'] = $this->makeElementId($field, $form);
79 + $nameTitleClass = '';
80 + $atts = $this->buildAttributes($field['attributes']);
66 81
67 - $elMarkup = "<input ".$this->buildAttributes($field['attributes']).">";
82 + $ariaRequired = 'false';
83 + if (ArrayHelper::get($field, 'settings.validation_rules.required.value')) {
84 + $ariaRequired = 'true';
85 + }
68 86
87 + if ('select' == $field['attributes']['type']) {
88 + if (! defined('FLUENTFORMPRO')) {
89 + continue;
90 + }
91 + $nameTitleClass = ' ff-name-title';
92 +
93 + $defaultValues = (array) $this->extractValueFromAttributes($field);
94 +
95 + $options = $this->buildOptions($field, $defaultValues);
96 +
97 + $elMarkup = '<select ' . $atts . '>' . $options . '</select>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $atts and $options are escaped before being passed in.
98 + } else {
99 + $elMarkup = '<input ' . $atts . 'aria-invalid="false" aria-required='.$ariaRequired.'>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $atts is escaped before being passed in.
100 + }
101 +
69 102 $inputTextMarkup = $this->buildElementMarkup($elMarkup, $field, $form);
70 - $html .= "<div class='ff-t-cell'>{$inputTextMarkup}</div>";
103 + $html .= "<div class='ff-t-cell " . esc_attr($nameTitleClass) . "'>{$inputTextMarkup}</div>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $inputTextMarkup is escaped before being passed in.
71 104 }
72 105 }
73 - $html .= "</div>";
74 - $html .= "</div>";
75 - echo apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form);
106 + $html .= '</div>';
107 + $html .= '</div>';
108 +
109 + $html = apply_filters_deprecated(
110 + 'fluentform_rendering_field_html_' . $elementName,
111 + [
112 + $html,
113 + $data,
114 + $form
115 + ],
116 + FLUENTFORM_FRAMEWORK_UPGRADE,
117 + 'fluentform/rendering_field_html_' . $elementName,
118 + 'Use fluentform/rendering_field_html_' . $elementName . ' instead of fluentform_rendering_field_html_' . $elementName
119 + );
120 +
121 + $this->printContent('fluentform/rendering_field_html_' . $elementName, $html, $data, $form);
76 122 }
77 123 }