PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.21
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.21
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 / Address.php

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

66 lines 2.2 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 class Address extends BaseComponent
6 {
7 /**
8 * Wrapper class for address element
9 * @var string
10 */
11 protected $wrapperClass = 'fluent-address';
12
13 /**
14 * Compile and echo the html element
15 * @param array $data [element data]
16 * @param stdClass $form [Form Object]
17 * @return viod
18 */
19 public function compile($data, $form)
20 {
21 $elementName = $data['element'];
22 $data = apply_filters('fluenform_rendering_field_data_'.$elementName, $data, $form);
23
24 $rootName = $data['attributes']['name'];
25 $hasConditions = $this->hasConditions($data) ? 'has-conditions ' : '';
26 $data['attributes']['class'] .= ' ff-name-address-wrapper ' . $this->wrapperClass . ' ' . $hasConditions;
27 $data['attributes']['class'] = trim($data['attributes']['class']);
28 $atts = $this->buildAttributes(
29 \FluentForm\Framework\Helpers\ArrayHelper::except($data['attributes'], 'name')
30 );
31 ob_start();
32 echo "<div {$atts}>";
33 if($data['settings']['label']):
34 echo "<div class='ff-el-input--label'>";
35 echo "<label>{$data['settings']['label']}</label>";
36 echo "</div>";
37 endif;
38 echo "<div class='ff-el-input--content'>";
39
40 $visibleFields = array_chunk(array_filter($data['fields'], function($field) {
41 return $field['settings']['visible'];
42 }), 2);
43
44 foreach ($visibleFields as $chunked) {
45 echo "<div class='ff-t-container'>";
46 foreach ($chunked as $item) {
47 if($item['settings']['visible']) {
48 $itemName = $item['attributes']['name'];
49 $item['attributes']['name'] = $rootName.'['.$itemName.']';
50 $item = apply_filters('fluentform_before_render_item', $item, $form);
51 echo "<div class='ff-t-cell'>";
52 do_action('fluentform_render_item_'.$item['element'], $item, $form);
53 echo "</div>";
54 }
55 }
56 echo "</div>";
57 }
58
59 echo "</div>";
60 echo "</div>";
61
62 $html = ob_get_clean();
63 echo apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form);
64 }
65 }
66