| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Services\FormBuilder\Components; |
| 4 |
|
| 5 |
class TermsAndConditions extends BaseComponent |
| 6 |
{ |
| 7 |
/** |
| 8 |
* Compile and echo the html element |
| 9 |
* @param array $data [element data] |
| 10 |
* @param stdClass $form [Form Object] |
| 11 |
* @return viod |
| 12 |
*/ |
| 13 |
public function compile($data, $form) |
| 14 |
{ |
| 15 |
$elementName = $data['element']; |
| 16 |
$data = apply_filters('fluenform_rendering_field_data_' . $elementName, $data, $form); |
| 17 |
|
| 18 |
$hasConditions = $this->hasConditions($data) ? 'has-conditions ' : ''; |
| 19 |
|
| 20 |
$cls = trim( |
| 21 |
$this->getDefaultContainerClass() |
| 22 |
. ' ' . @$data['settings']['container_class'] |
| 23 |
. ' ' . $hasConditions |
| 24 |
.' ff-el-input--content' |
| 25 |
); |
| 26 |
|
| 27 |
$uniqueId = $this->getUniqueId($data['attributes']['name']); |
| 28 |
|
| 29 |
$data['attributes']['id'] = $uniqueId; |
| 30 |
$data['attributes']['class'] = trim( |
| 31 |
'ff-el-form-check-input ' . |
| 32 |
$data['attributes']['class'] |
| 33 |
); |
| 34 |
|
| 35 |
if($tabIndex = \FluentForm\App\Helpers\Helper::getNextTabIndex()) { |
| 36 |
$data['attributes']['tabindex'] = $tabIndex; |
| 37 |
} |
| 38 |
|
| 39 |
$atts = $this->buildAttributes($data['attributes']); |
| 40 |
$checkbox = ''; |
| 41 |
if ($data['settings']['has_checkbox']) { |
| 42 |
$checkbox = "<span class='ff_tc_checkbox'><input {$atts} value='on'></span>"; |
| 43 |
} |
| 44 |
|
| 45 |
$html = "<div class='{$cls}'>"; |
| 46 |
$html .= "<div class='ff-el-form-check ff-el-tc'>"; |
| 47 |
$html .= "<label class='ff-el-form-check-label ff_tc_label' for={$uniqueId}>"; |
| 48 |
$html .= "{$checkbox} <div class='ff_t_c'>{$data['settings']['tnc_html']}</div>"; |
| 49 |
$html .= "</label>"; |
| 50 |
$html .= "</div>"; |
| 51 |
$html .= "</div>"; |
| 52 |
echo apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form); |
| 53 |
} |
| 54 |
} |
| 55 |
|