PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.31
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.31
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 / FormBuilder / Components / Name.php

Name.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 3.6.31, at app/Services/FormBuilder/Components/Name.php

78 lines 2.6 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\FormBuilder\Components;
4
5 use FluentForm\App\Helpers\Helper;
6 use FluentForm\Framework\Helpers\ArrayHelper;
7
8 class Name extends BaseComponent
9 {
10 /**
11 * Compile and echo the html element
12 * @param array $data [element data]
13 * @param stdClass $form [Form Object]
14 * @return viod
15 */
16 public function compile($data, $form)
17 {
18 $elementName = $data['element'];
19
20 $data = apply_filters('fluenform_rendering_field_data_'.$elementName, $data, $form);
21
22 $rootName = $data['attributes']['name'];
23
24 $hasConditions = $this->hasConditions($data) ? 'has-conditions ' : '';
25
26 if (empty($data['attributes']['class'])) {
27 $data['attributes']['class'] = '';
28 }
29
30 $data['attributes']['class'] .= $hasConditions;
31 $data['attributes']['class'] .= ' ff-field_container ff-name-field-wrapper';
32 if($containerClass = ArrayHelper::get($data, 'settings.container_class')) {
33 $data['attributes']['class'] .= ' '.$containerClass;
34 }
35 $atts = $this->buildAttributes(
36 ArrayHelper::except($data['attributes'], 'name')
37 );
38
39 $html = "<div {$atts}>";
40 $html .= "<div class='ff-t-container'>";
41
42 $labelPlacement = ArrayHelper::get($data, 'settings.label_placement');
43 $labelPlacementClass = '';
44
45 if ($labelPlacement) {
46 $labelPlacementClass = ' ff-el-form-'.$labelPlacement;
47 }
48
49 foreach ($data['fields'] as $field) {
50 if ($field['settings']['visible']) {
51 $fieldName = $field['attributes']['name'];
52 $field['attributes']['name'] = $rootName . '[' . $fieldName . ']';
53 @$field['attributes']['class'] = trim(
54 'ff-el-form-control ' .
55 $field['attributes']['class']
56 );
57
58 if ($tabIndex = \FluentForm\App\Helpers\Helper::getNextTabIndex()) {
59 $field['attributes']['tabindex'] = $tabIndex;
60 }
61
62
63 @$field['settings']['container_class'] .= $labelPlacementClass;
64
65 $field['attributes']['id'] = $this->makeElementId($field, $form);
66
67 $elMarkup = "<input ".$this->buildAttributes($field['attributes']).">";
68
69 $inputTextMarkup = $this->buildElementMarkup($elMarkup, $field, $form);
70 $html .= "<div class='ff-t-cell'>{$inputTextMarkup}</div>";
71 }
72 }
73 $html .= "</div>";
74 $html .= "</div>";
75 echo apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form);
76 }
77 }
78