class TextareaWidget
Same name in other branches
- 9 core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php \Drupal\text\Plugin\Field\FieldWidget\TextareaWidget
- 8.9.x core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php \Drupal\text\Plugin\Field\FieldWidget\TextareaWidget
- 11.x core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php \Drupal\text\Plugin\Field\FieldWidget\TextareaWidget
Plugin implementation of the 'text_textarea' widget.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\Core\Field\PluginSettingsBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface
- class \Drupal\Core\Field\WidgetBase extends \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\WidgetInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextareaWidget extends \Drupal\Core\Field\WidgetBase
- class \Drupal\text\Plugin\Field\FieldWidget\TextareaWidget extends \Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextareaWidget
- class \Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextareaWidget extends \Drupal\Core\Field\WidgetBase
- class \Drupal\Core\Field\WidgetBase extends \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\WidgetInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\Core\Field\PluginSettingsBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of TextareaWidget
File
-
core/
modules/ text/ src/ Plugin/ Field/ FieldWidget/ TextareaWidget.php, line 15
Namespace
Drupal\text\Plugin\Field\FieldWidgetView source
class TextareaWidget extends StringTextareaWidget {
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
$element['rows']['#description'] = $this->t('Text editors may override this setting.');
return $element;
}
/**
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$main_widget = parent::formElement($items, $delta, $element, $form, $form_state);
$allowed_formats = $this->getFieldSetting('allowed_formats');
$element = $main_widget['value'];
$element['#type'] = 'text_format';
$element['#format'] = $items[$delta]->format;
$element['#base_type'] = $main_widget['value']['#type'];
if ($allowed_formats && !$this->isDefaultValueWidget($form_state)) {
$element['#allowed_formats'] = $allowed_formats;
}
return $element;
}
/**
* {@inheritdoc}
*/
public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) {
if (isset($element['format']['#access']) && !$element['format']['#access'] && preg_match('/^[0-9]*\\.format$/', $violation->getPropertyPath())) {
// Ignore validation errors for formats if formats may not be changed,
// such as when existing formats become invalid.
// See \Drupal\filter\Element\TextFormat::processFormat().
return FALSE;
}
return $element;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.