Drupal 8  8.0.2
PathWidget Class Reference
Inheritance diagram for PathWidget:

Public Member Functions

 formElement (FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state)
 
 errorElement (array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state)
 
- Public Member Functions inherited from WidgetBase
 __construct ($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings)
 
 form (FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta=NULL)
 
 extractFormValues (FieldItemListInterface $items, array $form, FormStateInterface $form_state)
 
 settingsForm (array $form, FormStateInterface $form_state)
 
 settingsSummary ()
 
 errorElement (array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state)
 
 massageFormValues (array $values, array $form, FormStateInterface $form_state)
 
- Public Member Functions inherited from PluginSettingsBase
 getSettings ()
 
 getSetting ($key)
 
 setSettings (array $settings)
 
 setSetting ($key, $value)
 
 getThirdPartySettings ($module=NULL)
 
 getThirdPartySetting ($module, $key, $default=NULL)
 
 setThirdPartySetting ($module, $key, $value)
 
 unsetThirdPartySetting ($module, $key)
 
 getThirdPartyProviders ()
 
 calculateDependencies ()
 
 onDependencyRemoval (array $dependencies)
 
- Public Member Functions inherited from PluginInspectionInterface
 getPluginId ()
 
 getPluginDefinition ()
 
- Public Member Functions inherited from WidgetBaseInterface
 flagErrors (FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state)
 

Static Public Member Functions

static validateFormElement (array &$element, FormStateInterface $form_state)
 
- Static Public Member Functions inherited from WidgetBase
static afterBuild (array $element, FormStateInterface $form_state)
 
static addMoreSubmit (array $form, FormStateInterface $form_state)
 
static addMoreAjax (array $form, FormStateInterface $form_state)
 
static getWidgetState (array $parents, $field_name, FormStateInterface $form_state)
 
static setWidgetState (array $parents, $field_name, FormStateInterface $form_state, array $field_state)
 
static isApplicable (FieldDefinitionInterface $field_definition)
 
- Static Public Member Functions inherited from PluginSettingsBase
static defaultSettings ()
 

Additional Inherited Members

- Protected Member Functions inherited from WidgetBase
 formMultipleElements (FieldItemListInterface $items, array &$form, FormStateInterface $form_state)
 
 formSingleElement (FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state)
 
 getFieldSettings ()
 
 getFieldSetting ($setting_name)
 
 handlesMultipleValues ()
 
 isDefaultValueWidget (FormStateInterface $form_state)
 
- Protected Member Functions inherited from PluginSettingsBase
 mergeDefaults ()
 
- Static Protected Member Functions inherited from WidgetBase
static getWidgetStateParents (array $parents, $field_name)
 
- Protected Attributes inherited from WidgetBase
 $fieldDefinition
 
 $settings
 
- Protected Attributes inherited from PluginSettingsBase
 $settings = array()
 
 $thirdPartySettings = array()
 
 $defaultSettingsMerged = FALSE
 

Detailed Description

Plugin implementation of the 'path' widget.

( id = "path", label = ("URL alias"), field_types = { "path" } )

Member Function Documentation

errorElement ( array  $element,
ConstraintViolationInterface  $violation,
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$elementAn array containing the form element for the widget, as generated by formElement().
\Symfony\Component\Validator\ConstraintViolationInterface$violationA constraint violation reported during the validation phase.
array$formThe form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
Returns
array|bool The element on which the error should be flagged, or FALSE to completely ignore the violation (use with care!).
}

Implements WidgetInterface.

formElement ( FieldItemListInterface  $items,
  $delta,
array  $element,
array &  $form,
FormStateInterface  $form_state 
)

{Returns the form for a single field widget.Field widget form elements should be based on the passed-in $element, which contains the base form element properties derived from the field configuration.The BaseWidget methods will set the weight, field name and delta values for each form element. If there are multiple values for this field, the formElement() method will be called as many times as needed.Other modules may alter the form element provided by this function using hook_field_widget_form_alter() or hook_field_widget_WIDGET_TYPE_form_alter().The FAPI element callbacks (such as #process, #element_validate, #value_callback, etc.) used by the widget do not have access to the original $field_definition passed to the widget's constructor. Therefore, if any information is needed from that definition by those callbacks, the widget implementing this method, or a hook_field_widget[_WIDGET_TYPE]_form_alter() implementation, must extract the needed properties from the field definition and set them as ad-hoc $element['#custom'] properties, for later use by its element callbacks.

Parameters
\Drupal\Core\Field\FieldItemListInterface$itemsArray of default values for this field.
int$deltaThe order of this item in the array of sub-elements (0, 1, 2, etc.).
array$elementA form element array containing basic properties for the widget:
  • #field_parents: The 'parents' space for the field in the form. Most widgets can simply overlook this property. This identifies the location where the field values are placed within $form_state->getValues(), and is used to access processing information for the field through the getWidgetState() and setWidgetState() methods.
  • #title: The sanitized element label for the field, ready for output.
  • #description: The sanitized element description for the field, ready for output.
  • #required: A Boolean indicating whether the element value is required; for required multiple value fields, only the first widget's values are required.
  • #delta: The order of this item in the array of sub-elements; see $delta above.
array$formThe form structure where widgets are being attached to. This might be a full form structure, or a sub-element of a larger form.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
Returns
array The form elements for a single widget for this field.
See Also
hook_field_widget_form_alter()
hook_field_widget_WIDGET_TYPE_form_alter()
}

Implements WidgetInterface.

References FieldItemListInterface\getEntity(), FieldItemListInterface\getLangcode(), LanguageInterface\LANGCODE_NOT_SPECIFIED, Drupal\service(), and t().

Here is the call graph for this function:

static validateFormElement ( array &  $element,
FormStateInterface  $form_state 
)
static

Form element validation handler for URL alias form element.

Parameters
array$elementThe form element.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state.

References Drupal\service(), FormStateInterface\setError(), FormStateInterface\setValueForElement(), and t().

Here is the call graph for this function:


The documentation for this class was generated from the following file: