Textarea.php in YAML Form 8
File
src/Plugin/YamlFormElement/Textarea.php
View source
<?php
namespace Drupal\yamlform\Plugin\YamlFormElement;
use Drupal\Component\Render\HtmlEscapedText;
use Drupal\Core\Form\FormStateInterface;
class Textarea extends TextBase {
public function getDefaultProperties() {
return [
'title' => '',
'description' => '',
'default_value' => '',
'title_display' => '',
'description_display' => '',
'field_prefix' => '',
'field_suffix' => '',
'placeholder' => '',
'rows' => '',
'required' => FALSE,
'required_error' => '',
'unique' => FALSE,
'counter_type' => '',
'counter_maximum' => '',
'counter_message' => '',
'format' => $this
->getDefaultFormat(),
] + $this
->getDefaultBaseProperties();
}
public function getTranslatableProperties() {
return array_merge(parent::getTranslatableProperties(), [
'counter_message',
]);
}
public function formatHtml(array &$element, $value, array $options = []) {
return [
'#markup' => nl2br(new HtmlEscapedText($value)),
];
}
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['general']['default_value']['#type'] = 'textarea';
return $form;
}
}