| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Services\FormBuilder\Components; |
| 4 |
|
| 5 |
use FluentForm\App\Helpers\Helper; |
| 6 |
|
| 7 |
class TextArea extends BaseComponent |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Compile and echo the html element |
| 11 |
* |
| 12 |
* @param array $data [element data] |
| 13 |
* @param \stdClass $form [Form Object] |
| 14 |
* |
| 15 |
* @return void |
| 16 |
*/ |
| 17 |
public function compile($data, $form) |
| 18 |
{ |
| 19 |
$elementName = $data['element']; |
| 20 |
$data = apply_filters('fluentform_rendering_field_data_' . $elementName, $data, $form); |
| 21 |
|
| 22 |
$textareaValue = $this->extractValueFromAttributes($data); |
| 23 |
|
| 24 |
$data['attributes']['class'] = trim('ff-el-form-control ' . $data['attributes']['class']); |
| 25 |
$data['attributes']['id'] = $this->makeElementId($data, $form); |
| 26 |
|
| 27 |
if ($tabIndex = Helper::getNextTabIndex()) { |
| 28 |
$data['attributes']['tabindex'] = $tabIndex; |
| 29 |
} |
| 30 |
|
| 31 |
$elMarkup = '<textarea %s>%s</textarea>'; |
| 32 |
|
| 33 |
$atts = $this->buildAttributes($data['attributes']); |
| 34 |
|
| 35 |
$elMarkup = sprintf( |
| 36 |
$elMarkup, |
| 37 |
$atts, |
| 38 |
esc_attr($textareaValue) |
| 39 |
); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $atts is escaped before being passed in. |
| 40 |
|
| 41 |
$html = $this->buildElementMarkup($elMarkup, $data, $form); |
| 42 |
|
| 43 |
$this->printContent('fluentform_rendering_field_html_' . $elementName, $html, $data, $form); |
| 44 |
} |
| 45 |
} |
| 46 |
|