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.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 / Services / FormBuilder / BaseFieldManager.php

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

132 lines 3.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\Services\FormBuilder;
4
5 use FluentForm\App\Services\FormBuilder\Components\BaseComponent;
6
7 abstract class BaseFieldManager extends BaseComponent
8 {
9 protected $key = '';
10 protected $title = '';
11 protected $tags = [];
12 protected $position = 'advanced';
13
14 public function __construct($key, $title, $tags = [], $position = 'advanced')
15 {
16 $this->key = $key;
17 $this->position = $position;
18 $this->title = $title;
19 $this->tags = $tags;
20 $this->register();
21 }
22
23 public function register()
24 {
25 add_filter('fluent_editor_components', array($this, 'pushComponent'));
26 add_filter('fluent_editor_element_settings_placement', array($this, 'pushEditorElementPositions'));
27 add_filter('fluent_editor_element_search_tags', array($this, 'pushTags'), 10, 2);
28 add_action('fluentform_render_item_' . $this->key, array($this, 'render'), 10, 2);
29 /*
30 * This is internal use.
31 * Push field type to the fluentform field types to be available in FormFieldParser.
32 */
33 add_filter('fluentform_form_input_types', array($this, 'pushFormInputType'));
34
35 add_filter('fluent_editor_element_customization_settings', function ($settings) {
36 if ($customSettings = $this->getEditorCustomizationSettings()) {
37 $settings = array_merge($settings, $customSettings);
38 }
39
40 return $settings;
41 });
42
43
44 add_filter('fluentform_supported_conditional_fields', array($this, 'pushConditionalSupport'));
45
46 }
47
48 public function pushConditionalSupport($conditonalItems)
49 {
50 $conditonalItems[] = $this->key;
51 return $conditonalItems;
52 }
53
54 public function pushFormInputType($types)
55 {
56 $types[] = $this->key;
57 return $types;
58 }
59
60 public function pushComponent($components)
61 {
62 $component = $this->getComponent();
63
64 if ($component) {
65 $components[$this->position][] = $component;
66 }
67
68 return $components;
69 }
70
71 public function pushEditorElementPositions($placement_settings)
72 {
73 $placement_settings[$this->key] = array(
74 'general' => $this->getGeneralEditorElements(),
75 'advanced' => $this->getAdvancedEditorElements(),
76 'generalExtras' => $this->generalEditorElement(),
77 'advancedExtras' => $this->advancedEditorElement()
78 );
79
80 return $placement_settings;
81 }
82
83 public function generalEditorElement()
84 {
85 return [];
86 }
87
88 public function advancedEditorElement()
89 {
90 return [];
91 }
92
93 public function getGeneralEditorElements()
94 {
95 return [
96 'label',
97 'admin_field_label',
98 'placeholder',
99 'label_placement',
100 'validation_rules',
101 ];
102 }
103
104 public function getAdvancedEditorElements()
105 {
106 return [
107 'name',
108 'help_message',
109 'container_class',
110 'class',
111 'conditional_logics',
112 ];
113 }
114
115 public function getEditorCustomizationSettings()
116 {
117 return [];
118 }
119
120 public function pushTags($tags, $form)
121 {
122 if ($this->tags) {
123 $tags[$this->key] = $this->tags;
124 }
125 return $tags;
126 }
127
128 abstract function getComponent();
129
130 abstract function render($element, $form);
131 }
132