WidgetBase::form

public WidgetBase::form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL) Creates a form element for a field. If the entity associated with the form is new (i.e., $entity->isNew() is TRUE), the 'default value', if any, is pre-populated. Also allows other modules to alter the form element by implementing their own hooks. Parameters \Drupal\Core\Field\FieldItemListInterface $items: An array of the field values. When creating a new entity this

WidgetBase::$fieldDefinition

The field definition. Type: \Drupal\Core\Field\FieldDefinitionInterface File core/lib/Drupal/Core/Field/WidgetBase.php, line 27 Class WidgetBase Base class for 'Field widget' plugin implementations. Namespace Drupal\Core\Field Code protected $fieldDefinition;

WidgetBase::addMoreAjax

public static WidgetBase::addMoreAjax(array $form, FormStateInterface $form_state) Ajax callback for the "Add another item" button. This returns the new page content to replace the page content made obsolete by the form submission. File core/lib/Drupal/Core/Field/WidgetBase.php, line 291 Class WidgetBase Base class for 'Field widget' plugin implementations. Namespace Drupal\Core\Field Code public static function addMoreAjax(array $form, FormStateInterface $form_state) { $button = $fo

WidgetBase::afterBuild

public static WidgetBase::afterBuild(array $element, FormStateInterface $form_state) After-build handler for field elements in a form. This stores the final location of the field within the form structure so that flagErrors() can assign validation errors to the right form element. File core/lib/Drupal/Core/Field/WidgetBase.php, line 255 Class WidgetBase Base class for 'Field widget' plugin implementations. Namespace Drupal\Core\Field Code public static function afterBuild(array $elemen

WidgetBase::errorElement

public WidgetBase::errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) Assigns a field-level validation error to the right widget sub-element. Depending on the widget's internal structure, a field-level validation error needs to be flagged on the right sub-element. Parameters array $element: An array containing the form element for the widget, as generated by formElement(). \Symfony\Component\Validator\ConstraintViolationInterface $vio

WidgetBase::$settings

The widget settings. Type: array Overrides PluginSettingsBase::$settings File core/lib/Drupal/Core/Field/WidgetBase.php, line 34 Class WidgetBase Base class for 'Field widget' plugin implementations. Namespace Drupal\Core\Field Code protected $settings;

WidgetBase::addMoreSubmit

public static WidgetBase::addMoreSubmit(array $form, FormStateInterface $form_state) Submission handler for the "Add another item" button. File core/lib/Drupal/Core/Field/WidgetBase.php, line 269 Class WidgetBase Base class for 'Field widget' plugin implementations. Namespace Drupal\Core\Field Code public static function addMoreSubmit(array $form, FormStateInterface $form_state) { $button = $form_state->getTriggeringElement(); // Go one level up in the form, to the widgets cont

WidgetBase

Base class for 'Field widget' plugin implementations. Hierarchy class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterfaceclass \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, StringTranslationTraitclass \Drupal\Core\Field\PluginSettingsBase implements DependentPluginInterface, PluginSettingsInterfaceclass \Drupal\Core\Field\WidgetBase implements WidgetInterface uses AllowedTagsXssTrait Related topics Field Widget API De

Weight::processWeight

public static Weight::processWeight(&$element, FormStateInterface $form_state, &$complete_form) Expands a weight element into a select element. File core/lib/Drupal/Core/Render/Element/Weight.php, line 50 Class Weight Provides a form element for input of a weight. Namespace Drupal\Core\Render\Element Code public static function processWeight(&$element, FormStateInterface $form_state, &$complete_form) { $element['#is_weight'] = TRUE; $element_info_manager = \Drupal:

Weight

Provides a form element for input of a weight. Weights are integers used to indicate ordering, with larger numbers later in the order. Properties: #delta: The range of possible weight values used. A delta of 10 would indicate possible weight values between -10 and 10. Usage example: $form['weight'] = array( '#type' => 'weight', '#title' => $this->t('Weight'), '#default_value' => $edit['weight'], '#delta' => 10, ); Plugin annotation @FormElement("weight") Hierarchy cl