class FieldWidget

Same name in this branch
  1. 10 core/lib/Drupal/Core/Field/Annotation/FieldWidget.php \Drupal\Core\Field\Annotation\FieldWidget
Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Field/Annotation/FieldWidget.php \Drupal\Core\Field\Annotation\FieldWidget
  2. 8.9.x core/lib/Drupal/Core/Field/Annotation/FieldWidget.php \Drupal\Core\Field\Annotation\FieldWidget
  3. 11.x core/lib/Drupal/Core/Field/Attribute/FieldWidget.php \Drupal\Core\Field\Attribute\FieldWidget
  4. 11.x core/lib/Drupal/Core/Field/Annotation/FieldWidget.php \Drupal\Core\Field\Annotation\FieldWidget

Defines a FieldWidget attribute for plugin discovery.

Plugin Namespace: Plugin\Field\FieldWidget

Widgets handle how fields are displayed in edit forms.

Additional attribute keys for widgets can be defined in hook_field_widget_info_alter().

Attributes

#[\Attribute(\Attribute::TARGET_CLASS)]

Hierarchy

Expanded class hierarchy of FieldWidget

See also

\Drupal\Core\Field\WidgetPluginManager

\Drupal\Core\Field\WidgetInterface

Related topics

38 files declare their use of FieldWidget
BooleanCheckboxWidget.php in core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php
CommentWidget.php in core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php
DateRangeDatelistWidget.php in core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeDatelistWidget.php
DateRangeDefaultWidget.php in core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeDefaultWidget.php
DateTimeDatelistWidget.php in core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php

... See full list

File

core/lib/Drupal/Core/Field/Attribute/FieldWidget.php, line 23

Namespace

Drupal\Core\Field\Attribute
View source
class FieldWidget extends Plugin {
  
  /**
   * Constructs a FieldWidget attribute.
   *
   * @param string $id
   *   The plugin ID.
   * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $label
   *   (optional) The human-readable name of the widget type.
   * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
   *   (optional) A short description of the widget type.
   * @param string[] $field_types
   *   (optional) An array of field types the widget supports.
   * @param bool $multiple_values
   *   (optional) Does the field widget handles multiple values at once.
   * @param int|null $weight
   *   (optional) An integer to determine weight of this widget relative to
   *   other widgets. Other widgets are in the Field UI when selecting a widget
   *   for a given field.
   * @param class-string|null $deriver
   *   (optional) The deriver class.
   */
  public function __construct(public readonly string $id, public readonly ?TranslatableMarkup $label = NULL, public readonly ?TranslatableMarkup $description = NULL, public readonly array $field_types = [], public readonly bool $multiple_values = FALSE, public readonly ?int $weight = NULL, public readonly ?string $deriver = NULL) {
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AttributeBase::$class protected property The class used for this attribute class.
AttributeBase::$provider protected property The provider of the attribute class.
AttributeBase::get public function Gets the value of an attribute. Overrides AttributeInterface::get 1
AttributeBase::getClass public function Gets the class of the attribute class. Overrides AttributeInterface::getClass
AttributeBase::getId public function Gets the unique ID for this attribute class. Overrides AttributeInterface::getId
AttributeBase::getProvider public function Gets the name of the provider of the attribute class. Overrides AttributeInterface::getProvider
AttributeBase::setClass public function Sets the class of the attributed class. Overrides AttributeInterface::setClass
AttributeBase::setProvider public function Sets the name of the provider of the attribute class. Overrides AttributeInterface::setProvider
FieldWidget::__construct public function Constructs a FieldWidget attribute. Overrides Plugin::__construct

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.