Chris@0: getValues(), and is used to access processing Chris@0: * information for the field through the getWidgetState() and Chris@0: * setWidgetState() methods. Chris@0: * - #title: The sanitized element label for the field, ready for output. Chris@0: * - #description: The sanitized element description for the field, ready Chris@0: * for output. Chris@0: * - #required: A Boolean indicating whether the element value is required; Chris@0: * for required multiple value fields, only the first widget's values are Chris@0: * required. Chris@0: * - #delta: The order of this item in the array of sub-elements; see $delta Chris@0: * above. Chris@0: * @param array $form Chris@0: * The form structure where widgets are being attached to. This might be a Chris@0: * full form structure, or a sub-element of a larger form. Chris@0: * @param \Drupal\Core\Form\FormStateInterface $form_state Chris@0: * The current state of the form. Chris@0: * Chris@0: * @return array Chris@0: * The form elements for a single widget for this field. Chris@0: * Chris@0: * @see hook_field_widget_form_alter() Chris@0: * @see hook_field_widget_WIDGET_TYPE_form_alter() Chris@0: */ Chris@0: public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state); Chris@0: Chris@0: /** Chris@0: * Assigns a field-level validation error to the right widget sub-element. Chris@0: * Chris@0: * Depending on the widget's internal structure, a field-level validation Chris@0: * error needs to be flagged on the right sub-element. Chris@0: * Chris@0: * @param array $element Chris@0: * An array containing the form element for the widget, as generated by Chris@0: * formElement(). Chris@0: * @param \Symfony\Component\Validator\ConstraintViolationInterface $violation Chris@0: * A constraint violation reported during the validation phase. Chris@0: * @param array $form Chris@0: * The form structure where field elements are attached to. This might be a Chris@0: * full form structure, or a sub-element of a larger form. Chris@0: * @param \Drupal\Core\Form\FormStateInterface $form_state Chris@0: * The current state of the form. Chris@0: * Chris@0: * @return array|bool Chris@0: * The element on which the error should be flagged, or FALSE to completely Chris@0: * ignore the violation (use with care!). Chris@0: */ Chris@0: public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state); Chris@0: Chris@0: /** Chris@0: * Massages the form values into the format expected for field values. Chris@0: * Chris@0: * @param array $values Chris@0: * The submitted form values produced by the widget. Chris@0: * - If the widget does not manage multiple values itself, the array holds Chris@0: * the values generated by the multiple copies of the $element generated Chris@0: * by the formElement() method, keyed by delta. Chris@0: * - If the widget manages multiple values, the array holds the values Chris@0: * of the form element generated by the formElement() method. Chris@0: * @param array $form Chris@0: * The form structure where field elements are attached to. This might be a Chris@0: * full form structure, or a sub-element of a larger form. Chris@0: * @param \Drupal\Core\Form\FormStateInterface $form_state Chris@0: * The form state. Chris@0: * Chris@0: * @return array Chris@0: * An array of field values, keyed by delta. Chris@0: */ Chris@0: public function massageFormValues(array $values, array $form, FormStateInterface $form_state); Chris@0: Chris@0: /** Chris@0: * Returns if the widget can be used for the provided field. Chris@0: * Chris@0: * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition Chris@0: * The field definition that should be checked. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE if the widget can be used, FALSE otherwise. Chris@0: */ Chris@0: public static function isApplicable(FieldDefinitionInterface $field_definition); Chris@0: Chris@0: }