Drupal 8  8.0.2
EntityReferenceAutocompleteWidget Class Reference
Inheritance diagram for EntityReferenceAutocompleteWidget:

Public Member Functions

 settingsForm (array $form, FormStateInterface $form_state)
 
 settingsSummary ()
 
 formElement (FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state)
 
 errorElement (array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state)
 
 massageFormValues (array $values, 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 defaultSettings ()
 
- 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 ()
 

Protected Member Functions

 getAutocreateBundle ()
 
 getSelectionHandlerSetting ($setting_name)
 
 getMatchOperatorOptions ()
 
- 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 ()
 

Additional Inherited Members

- 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 'entity_reference_autocomplete' widget.

( id = "entity_reference_autocomplete", label = ("Autocomplete"), description = ("An autocomplete text field."), field_types = { "entity_reference" } )

Member Function Documentation

static defaultSettings ( )
static

{Defines the default settings for this plugin.

Returns
array A list of default settings, keyed by the setting name.
}

Implements PluginSettingsInterface.

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$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 Drupal\currentUser(), EntityReferenceAutocompleteWidget\getAutocreateBundle(), FieldItemListInterface\getEntity(), WidgetBase\getFieldSetting(), EntityReferenceAutocompleteWidget\getSelectionHandlerSetting(), and PluginSettingsBase\getSetting().

Here is the call graph for this function:

getAutocreateBundle ( )
protected

Returns the name of the bundle which will be used for autocreated entities.

Returns
string The bundle name.

References WidgetBase\getFieldSetting(), and EntityReferenceAutocompleteWidget\getSelectionHandlerSetting().

Referenced by EntityReferenceAutocompleteWidget\formElement().

Here is the call graph for this function:

Here is the caller graph for this function:

getMatchOperatorOptions ( )
protected

Returns the options for the match operator.

Returns
array List of options.

References t().

Referenced by EntityReferenceAutocompleteWidget\settingsForm(), and EntityReferenceAutocompleteWidget\settingsSummary().

Here is the call graph for this function:

Here is the caller graph for this function:

getSelectionHandlerSetting (   $setting_name)
protected

Returns the value of a setting for the entity reference selection handler.

Parameters
string$setting_nameThe setting name.
Returns
mixed The setting value.

References WidgetBase\getFieldSetting().

Referenced by EntityReferenceAutocompleteWidget\formElement(), and EntityReferenceAutocompleteWidget\getAutocreateBundle().

Here is the call graph for this function:

Here is the caller graph for this function:

massageFormValues ( array  $values,
array  $form,
FormStateInterface  $form_state 
)

{Massages the form values into the format expected for field values.

Parameters
array$valuesThe submitted form values produced by the widget.
  • If the widget does not manage multiple values itself, the array holds the values generated by the multiple copies of the $element generated by the formElement() method, keyed by delta.
  • If the widget manages multiple values, the array holds the values of the form element generated by the formElement() method.
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 form state.
Returns
array An array of field values, keyed by delta.
}

Implements WidgetInterface.

settingsForm ( array  $form,
FormStateInterface  $form_state 
)

{Returns a form to configure settings for the widget.Invoked from to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.

Parameters
array$formThe form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
Returns
array The form definition for the widget settings.
}

Implements WidgetInterface.

References EntityReferenceAutocompleteWidget\getMatchOperatorOptions(), PluginSettingsBase\getSetting(), and t().

Here is the call graph for this function:

settingsSummary ( )

{Returns a short summary for the current widget settings.If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.

Returns
array A short summary of the widget settings.
}

Implements WidgetInterface.

References EntityReferenceAutocompleteWidget\getMatchOperatorOptions(), PluginSettingsBase\getSetting(), and t().

Here is the call graph for this function:


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