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 / SubmitButton.php

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

107 lines 4.3 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 SubmitButton 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
19 if(apply_filters('fluentform_is_hide_submit_btn_'.$form->id, false)) {
20 return '';
21 }
22
23 $elementName = $data['element'];
24 $data = apply_filters('fluenform_rendering_field_data_'.$elementName, $data, $form);
25
26 $btnSize = 'ff-btn-';
27 $color = isset($data['settings']['color']) ? $data['settings']['color'] : '#ffffff';
28 $btnSize .= isset($data['settings']['button_size']) ? $data['settings']['button_size'] : 'md';
29 $backgroundColor = isset($data['settings']['background_color']) ? $data['settings']['background_color'] : '#409EFF';
30 $oldBtnType = isset($data['settings']['button_style']) ? '' : ' ff-btn-primary ';
31
32 $align = 'ff-el-group ff-text-' . @$data['settings']['align'];
33 $data['attributes']['class'] = trim(
34 'ff-btn ff-btn-submit ' . ' ' .
35 $oldBtnType . ' ' .
36 $btnSize . ' ' .
37 $data['attributes']['class']
38 );
39
40 if($tabIndex = \FluentForm\App\Helpers\Helper::getNextTabIndex()) {
41 $data['attributes']['tabindex'] = $tabIndex;
42 }
43
44 $styles = '';
45 if (ArrayHelper::get($data, 'settings.button_style') == '') {
46 $data['attributes']['class'] .= ' wpf_has_custom_css';
47 // it's a custom button
48 $buttonActiveStyles = ArrayHelper::get($data, 'settings.normal_styles', []);
49 $buttonHoverStyles = ArrayHelper::get($data, 'settings.hover_styles', []);
50
51 $activeStates = '';
52 foreach ($buttonActiveStyles as $styleAtr => $styleValue) {
53 if (!$styleValue) {
54 continue;
55 }
56 if ($styleAtr == 'borderRadius') {
57 $styleValue .= 'px';
58 }
59 $activeStates .= ltrim(strtolower(preg_replace('/[A-Z]([A-Z](?![a-z]))*/', '-$0', $styleAtr)), '_') . ':' . $styleValue . ';';
60 }
61 if ($activeStates) {
62 $styles .= 'form.fluent_form_' . $form->id . ' .wpf_has_custom_css.ff-btn-submit { ' . $activeStates . ' }';
63 }
64 $hoverStates = '';
65 foreach ($buttonHoverStyles as $styleAtr => $styleValue) {
66 if (!$styleValue) {
67 continue;
68 }
69 if ($styleAtr == 'borderRadius') {
70 $styleValue .= 'px';
71 }
72 $hoverStates .= ltrim(strtolower(preg_replace('/[A-Z]([A-Z](?![a-z]))*/', '-$0', $styleAtr)), '-') . ':' . $styleValue . ';';
73 }
74 if ($hoverStates) {
75 $styles .= 'form.fluent_form_' . $form->id . ' .wpf_has_custom_css.ff-btn-submit:hover { ' . $hoverStates . ' } ';
76 }
77 } else {
78 $styles .= 'form.fluent_form_' . $form->id . ' .ff-btn-submit { background-color: '.ArrayHelper::get($data, 'settings.background_color').'; color: '.ArrayHelper::get($data, 'settings.color').'; }';
79 }
80
81 $atts = $this->buildAttributes($data['attributes']);
82 $cls = trim($align . ' ' . $data['settings']['container_class']);
83
84
85 $html = "<div class='{$cls} ff_submit_btn_wrapper'>";
86
87 // ADDED IN v1.2.6 - updated in 1.4.4
88 if (isset($data['settings']['button_ui'])) {
89 if ($data['settings']['button_ui']['type'] == 'default') {
90 $html .= '<button ' . $atts . '>' . $data['settings']['button_ui']['text'] . '</button>';
91 } else {
92 $html .= "<button class='ff-btn-submit' type='submit'><img style='max-width: 200px;' src='{$data['settings']['button_ui']['img_url']}' alt='Submit Form'></button>";
93 }
94 } else {
95 $html .= '<button ' . $atts . '>' . $data['settings']['btn_text'] . '</button>';
96 }
97
98 if($styles) {
99 $html .= '<style>'.$styles.'</style>';
100 }
101
102 $html .= '</div>';
103
104 echo apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form);
105 }
106 }
107