| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Services\FormBuilder\Components; |
| 4 |
|
| 5 |
use FluentForm\Framework\Helpers\ArrayHelper; |
| 6 |
|
| 7 |
class CustomHtml extends BaseComponent |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Compile and echo the html element |
| 11 |
* @param array $data [element data] |
| 12 |
* @param stdClass $form [Form Object] |
| 13 |
* @return viod |
| 14 |
*/ |
| 15 |
public function compile($data, $form) |
| 16 |
{ |
| 17 |
$elementName = $data['element']; |
| 18 |
$data = apply_filters('fluenform_rendering_field_data_'.$elementName, $data, $form); |
| 19 |
|
| 20 |
$hasConditions = $this->hasConditions($data) ? 'has-conditions ' : ''; |
| 21 |
$cls = trim($this->getDefaultContainerClass() .' '.$hasConditions); |
| 22 |
if($containerClass = ArrayHelper::get($data, 'settings.container_class')) { |
| 23 |
$cls .= ' '.$containerClass; |
| 24 |
} |
| 25 |
$atts = $this->buildAttributes( |
| 26 |
\FluentForm\Framework\Helpers\ArrayHelper::except($data['attributes'], 'name') |
| 27 |
); |
| 28 |
$html = "<div class='{$cls}' {$atts}>{$data['settings']['html_codes']}</div>"; |
| 29 |
$html = apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form); |
| 30 |
echo $html; |
| 31 |
} |
| 32 |
} |
| 33 |
|