Drupal 8  8.0.2
EntityAutocomplete Class Reference
Inheritance diagram for EntityAutocomplete:

Public Member Functions

 getInfo ()
 
- Public Member Functions inherited from Textfield
 getInfo ()
 
- Public Member Functions inherited from PluginInspectionInterface
 getPluginId ()
 
 getPluginDefinition ()
 

Static Public Member Functions

static valueCallback (&$element, $input, FormStateInterface $form_state)
 
static processEntityAutocomplete (array &$element, FormStateInterface $form_state, array &$complete_form)
 
static getEntityLabels (array $entities)
 
static extractEntityIdFromAutocompleteInput ($input)
 
- Static Public Member Functions inherited from Textfield
static valueCallback (&$element, $input, FormStateInterface $form_state)
 
static preRenderTextfield ($element)
 
- Static Public Member Functions inherited from FormElement
static valueCallback (&$element, $input, FormStateInterface $form_state)
 
static processPattern (&$element, FormStateInterface $form_state, &$complete_form)
 
static validatePattern (&$element, FormStateInterface $form_state, &$complete_form)
 
- Static Public Member Functions inherited from RenderElement
static setAttributes (&$element, $class=array())
 
static preRenderGroup ($element)
 
static processAjaxForm (&$element, FormStateInterface $form_state, &$complete_form)
 
static preRenderAjaxForm ($element)
 
static processGroup (&$element, FormStateInterface $form_state, &$complete_form)
 

Static Protected Member Functions

static matchEntityByTitle (SelectionInterface $handler, $input, array &$element, FormStateInterface $form_state, $strict)
 

Detailed Description

Provides an entity autocomplete form element.

The #default_value accepted by this element is either an entity object or an array of entity objects.

("entity_autocomplete")

Member Function Documentation

static extractEntityIdFromAutocompleteInput (   $input)
static

Extracts the entity ID from the autocompletion result.

Parameters
string$inputThe input coming from the autocompletion result.
Returns
mixed|null An entity ID or NULL if the input does not contain one.

Referenced by LinkWidget\getUserEnteredStringAsUri().

Here is the caller graph for this function:

static getEntityLabels ( array  $entities)
static

Converts an array of entity objects into a string of entity labels.

This method is also responsible for checking the 'view' access on the passed-in entities.

Parameters
\Drupal\Core\Entity\EntityInterface[]$entities An array of entity objects.
Returns
string A string of entity labels separated by commas.

References Tags\encode(), and t().

Referenced by EntityAutocompleteElementFormTest\getAutocompleteInput(), and LinkWidget\getUriAsDisplayableString().

Here is the call graph for this function:

Here is the caller graph for this function:

getInfo ( )

{Returns the element properties for this element.

Returns
array An array of element properties. See ::getInfo() for documentation of the standard properties of all elements, and the return value format.
}

Implements ElementInterface.

static matchEntityByTitle ( SelectionInterface  $handler,
  $input,
array &  $element,
FormStateInterface  $form_state,
  $strict 
)
staticprotected

Finds an entity from an autocomplete input without an explicit ID.

The method will return an entity ID if one single entity unambuguously matches the incoming input, and sill assign form errors otherwise.

Parameters
\Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface$handlerEntity reference selection plugin.
string$inputSingle string from autocomplete element.
array$elementThe form element to set a form error.
\Drupal\Core\Form\FormStateInterface$form_stateThe current form state.
bool$strictWhether to trigger a form error if an element from $input (eg. an entity) is not found.
Returns
int|null Value of a matching entity ID, or NULL if none.

References SelectionInterface\getReferenceableEntities(), FormStateInterface\setError(), and t().

Here is the call graph for this function:

static processEntityAutocomplete ( array &  $element,
FormStateInterface  $form_state,
array &  $complete_form 
)
static

Adds entity autocomplete functionality to a form element.

Parameters
array$elementThe form element to process. Properties used:
  • #target_type: The ID of the target entity type.
  • #selection_handler: The plugin ID of the entity reference selection handler.
  • #selection_settings: An array of settings that will be passed to the selection handler.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
array$complete_formThe complete form structure.
Returns
array The form element.
Exceptions
\InvalidArgumentExceptionException thrown when the #target_type or #autocreate['bundle'] are missing.

References Drupal\currentUser(), Settings\getHashSalt(), Crypt\hmacBase64(), and Drupal\keyValue().

Here is the call graph for this function:

static valueCallback ( $element,
  $input,
FormStateInterface  $form_state 
)
static

{Determines how user input is mapped to an element's #value property.

Parameters
array$elementAn associative array containing the properties of the element.
mixed$inputThe incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
Returns
mixed The value to assign to the element.
}

Implements FormElementInterface.


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