Loading core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php +10 −9 Original line number Diff line number Diff line Loading @@ -3,22 +3,23 @@ namespace Drupal\Core\Datetime\Plugin\Field\FieldWidget; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Field\Attribute\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'datetime timestamp' widget. * * @FieldWidget( * id = "datetime_timestamp", * label = @Translation("Datetime Timestamp"), * field_types = { * "timestamp", * "created", * } * ) */ #[FieldWidget( id: 'datetime_timestamp', label: new TranslatableMarkup('Datetime Timestamp'), field_types: [ 'timestamp', 'created', ], )] class TimestampDatetimeWidget extends WidgetBase { /** Loading core/lib/Drupal/Core/Field/Attribute/FieldWidget.php 0 → 100644 +56 −0 Original line number Diff line number Diff line <?php namespace Drupal\Core\Field\Attribute; use Drupal\Component\Plugin\Attribute\Plugin; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * 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(). * * @see \Drupal\Core\Field\WidgetPluginManager * @see \Drupal\Core\Field\WidgetInterface * * @ingroup field_widget */ #[\Attribute(\Attribute::TARGET_CLASS)] 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, ) {} } core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php +8 −9 Original line number Diff line number Diff line Loading @@ -2,22 +2,21 @@ namespace Drupal\Core\Field\Plugin\Field\FieldWidget; use Drupal\Core\Field\Attribute\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'boolean_checkbox' widget. * * @FieldWidget( * id = "boolean_checkbox", * label = @Translation("Single on/off checkbox"), * field_types = { * "boolean" * }, * multiple_values = TRUE * ) */ #[FieldWidget( id: 'boolean_checkbox', label: new TranslatableMarkup('Single on/off checkbox'), field_types: ['boolean'], multiple_values: TRUE, )] class BooleanCheckboxWidget extends WidgetBase { /** Loading core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php +7 −8 Original line number Diff line number Diff line Loading @@ -2,22 +2,21 @@ namespace Drupal\Core\Field\Plugin\Field\FieldWidget; use Drupal\Core\Field\Attribute\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element\Email; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'email_default' widget. * * @FieldWidget( * id = "email_default", * label = @Translation("Email"), * field_types = { * "email" * } * ) */ #[FieldWidget( id: 'email_default', label: new TranslatableMarkup('Email'), field_types: ['email'], )] class EmailDefaultWidget extends WidgetBase { /** Loading core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteTagsWidget.php +9 −10 Original line number Diff line number Diff line Loading @@ -2,22 +2,21 @@ namespace Drupal\Core\Field\Plugin\Field\FieldWidget; use Drupal\Core\Field\Attribute\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'entity_reference_autocomplete_tags' widget. * * @FieldWidget( * id = "entity_reference_autocomplete_tags", * label = @Translation("Autocomplete (Tags style)"), * description = @Translation("An autocomplete text field with tagging support."), * field_types = { * "entity_reference" * }, * multiple_values = TRUE * ) */ #[FieldWidget( id: 'entity_reference_autocomplete_tags', label: new TranslatableMarkup('Autocomplete (Tags style)'), description: new TranslatableMarkup('An autocomplete text field with tagging support.'), field_types: ['entity_reference'], multiple_values: TRUE, )] class EntityReferenceAutocompleteTagsWidget extends EntityReferenceAutocompleteWidget { /** Loading Loading
core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php +10 −9 Original line number Diff line number Diff line Loading @@ -3,22 +3,23 @@ namespace Drupal\Core\Datetime\Plugin\Field\FieldWidget; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Field\Attribute\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'datetime timestamp' widget. * * @FieldWidget( * id = "datetime_timestamp", * label = @Translation("Datetime Timestamp"), * field_types = { * "timestamp", * "created", * } * ) */ #[FieldWidget( id: 'datetime_timestamp', label: new TranslatableMarkup('Datetime Timestamp'), field_types: [ 'timestamp', 'created', ], )] class TimestampDatetimeWidget extends WidgetBase { /** Loading
core/lib/Drupal/Core/Field/Attribute/FieldWidget.php 0 → 100644 +56 −0 Original line number Diff line number Diff line <?php namespace Drupal\Core\Field\Attribute; use Drupal\Component\Plugin\Attribute\Plugin; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * 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(). * * @see \Drupal\Core\Field\WidgetPluginManager * @see \Drupal\Core\Field\WidgetInterface * * @ingroup field_widget */ #[\Attribute(\Attribute::TARGET_CLASS)] 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, ) {} }
core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php +8 −9 Original line number Diff line number Diff line Loading @@ -2,22 +2,21 @@ namespace Drupal\Core\Field\Plugin\Field\FieldWidget; use Drupal\Core\Field\Attribute\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'boolean_checkbox' widget. * * @FieldWidget( * id = "boolean_checkbox", * label = @Translation("Single on/off checkbox"), * field_types = { * "boolean" * }, * multiple_values = TRUE * ) */ #[FieldWidget( id: 'boolean_checkbox', label: new TranslatableMarkup('Single on/off checkbox'), field_types: ['boolean'], multiple_values: TRUE, )] class BooleanCheckboxWidget extends WidgetBase { /** Loading
core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php +7 −8 Original line number Diff line number Diff line Loading @@ -2,22 +2,21 @@ namespace Drupal\Core\Field\Plugin\Field\FieldWidget; use Drupal\Core\Field\Attribute\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element\Email; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'email_default' widget. * * @FieldWidget( * id = "email_default", * label = @Translation("Email"), * field_types = { * "email" * } * ) */ #[FieldWidget( id: 'email_default', label: new TranslatableMarkup('Email'), field_types: ['email'], )] class EmailDefaultWidget extends WidgetBase { /** Loading
core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteTagsWidget.php +9 −10 Original line number Diff line number Diff line Loading @@ -2,22 +2,21 @@ namespace Drupal\Core\Field\Plugin\Field\FieldWidget; use Drupal\Core\Field\Attribute\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'entity_reference_autocomplete_tags' widget. * * @FieldWidget( * id = "entity_reference_autocomplete_tags", * label = @Translation("Autocomplete (Tags style)"), * description = @Translation("An autocomplete text field with tagging support."), * field_types = { * "entity_reference" * }, * multiple_values = TRUE * ) */ #[FieldWidget( id: 'entity_reference_autocomplete_tags', label: new TranslatableMarkup('Autocomplete (Tags style)'), description: new TranslatableMarkup('An autocomplete text field with tagging support.'), field_types: ['entity_reference'], multiple_values: TRUE, )] class EntityReferenceAutocompleteTagsWidget extends EntityReferenceAutocompleteWidget { /** Loading