Namespace
Drupal\field_permission_example\Plugin\Field\FieldWidget
File
-
modules/field_permission_example/src/Plugin/Field/FieldWidget/TextWidget.php
View source
<?php
namespace Drupal\field_permission_example\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
class TextWidget extends WidgetBase {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$value = $items[$delta]->value ?? '';
$element += [
'#type' => 'textarea',
'#default_value' => $value,
];
return [
'value' => $element,
];
}
}
Classes
| Title |
Deprecated |
Summary |
| TextWidget |
|
Plugin implementation of the 'field_permission_example_widget' widget. |