interface ElementInterface in Drupal 10
Same name in this branch
- 10 core/modules/config_translation/src/FormElement/ElementInterface.php \Drupal\config_translation\FormElement\ElementInterface
- 10 core/lib/Drupal/Core/Render/Element/ElementInterface.php \Drupal\Core\Render\Element\ElementInterface
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Render/Element/ElementInterface.php \Drupal\Core\Render\Element\ElementInterface
- 9 core/lib/Drupal/Core/Render/Element/ElementInterface.php \Drupal\Core\Render\Element\ElementInterface
Provides an interface for render element plugins.
Render element plugins allow modules to declare their own Render API element types and specify the default values for the properties. The values returned by the getInfo() method of the element plugin will be merged with the properties specified in render arrays. Thus, you can specify defaults for any Render API keys, in addition to those explicitly documented by \Drupal\Core\Render\ElementInfoManagerInterface::getInfo().
Some render elements are specifically form input elements; see \Drupal\Core\Render\Element\FormElementInterface for more information.
The public API of these objects must be designed with security in mind as render elements process raw user input.
Hierarchy
- interface \Drupal\Component\Plugin\PluginInspectionInterface; interface \Drupal\Core\Render\Element\RenderCallbackInterface
- interface \Drupal\Core\Render\Element\ElementInterface
Expanded class hierarchy of ElementInterface
All classes that implement ElementInterface
See also
\Drupal\Core\Render\ElementInfoManager
\Drupal\Core\Render\Annotation\RenderElement
\Drupal\Core\Render\Element\RenderElement
Related topics
File
- core/
lib/ Drupal/ Core/ Render/ Element/ ElementInterface.php, line 30
Namespace
Drupal\Core\Render\ElementView source
interface ElementInterface extends PluginInspectionInterface, RenderCallbackInterface {
/**
* Returns the element properties for this element.
*
* @return 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.
*/
public function getInfo();
/**
* Sets a form element's class attribute.
*
* Adds 'required' and 'error' classes as needed.
*
* @param array $element
* The form element.
* @param array $class
* Array of new class names to be added.
*/
public static function setAttributes(&$element, $class = []);
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ElementInterface:: |
public | function | Returns the element properties for this element. | 56 |
ElementInterface:: |
public static | function | Sets a form element's class attribute. | 1 |
PluginInspectionInterface:: |
public | function | Gets the definition of the plugin implementation. | 1 |
PluginInspectionInterface:: |
public | function | Gets the plugin_id of the plugin instance. | 1 |