interface FormElementInterface implements ElementInterface (View source)

Provides an interface for form element plugins.

Form element plugins are a subset of render elements, specifically representing HTML elements that take input as part of a form. Form element plugins are discovered via the same mechanism as regular render element plugins. See \Drupal\Core\Render\Element\ElementInterface for general information about render element plugins.

Methods

string
getPluginId()

Gets the plugin_id of the plugin instance.

array
getPluginDefinition()

Gets the definition of the plugin implementation.

array
getInfo()

Returns the element properties for this element.

static 
setAttributes(array $element, array $class = [])

Sets a form element's class attribute.

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

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

Details

string getPluginId()

Gets the plugin_id of the plugin instance.

Return Value

string

The plugin_id of the plugin instance.

array getPluginDefinition()

Gets the definition of the plugin implementation.

Return Value

array

The plugin definition, as returned by the discovery object used by the plugin manager.

array getInfo()

Returns the element properties for this element.

Return Value

array

An array of element properties. See \Drupal\Core\Render\ElementInfoManagerInterface::getInfo() for documentation of the standard properties of all elements, and the return value format.

static setAttributes(array $element, array $class = [])

Sets a form element's class attribute.

Adds 'required' and 'error' classes as needed.

Parameters

array $element

The form element.

array $class

Array of new class names to be added.

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

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

Parameters

array $element

An associative array containing the properties of the element.

mixed $input

The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.

FormStateInterface $form_state

The current state of the form.

Return Value

mixed

The value to assign to the element.