protected WidgetBase::formSingleElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state)
Generates the form element for a single copy of the widget.
protected function formSingleElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $entity = $items->getEntity(); $element += array( '#field_parents' => $form['#parents'], // Only the first widget should be required. '#required' => $delta == 0 && $this->fieldDefinition->isRequired(), '#delta' => $delta, '#weight' => $delta, ); $element = $this->formElement($items, $delta, $element, $form, $form_state); if ($element) { // Allow modules to alter the field widget form element. $context = array( 'form' => $form, 'widget' => $this, 'items' => $items, 'delta' => $delta, 'default' => $this->isDefaultValueWidget($form_state), ); \Drupal::moduleHandler()->alter(array('field_widget_form', 'field_widget_' . $this->getPluginId() . '_form'), $element, $form_state, $context); } return $element; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!WidgetBase.php/function/WidgetBase::formSingleElement/8.1.x