interface ElementInterface

Same name in this branch
  1. 8.9.x core/modules/config_translation/src/FormElement/ElementInterface.php \Drupal\config_translation\FormElement\ElementInterface
Same name in other branches
  1. 9 core/modules/config_translation/src/FormElement/ElementInterface.php \Drupal\config_translation\FormElement\ElementInterface
  2. 9 core/lib/Drupal/Core/Render/Element/ElementInterface.php \Drupal\Core\Render\Element\ElementInterface
  3. 10 core/modules/config_translation/src/FormElement/ElementInterface.php \Drupal\config_translation\FormElement\ElementInterface
  4. 10 core/lib/Drupal/Core/Render/Element/ElementInterface.php \Drupal\Core\Render\Element\ElementInterface
  5. 11.x core/modules/config_translation/src/FormElement/ElementInterface.php \Drupal\config_translation\FormElement\ElementInterface
  6. 11.x 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

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

Plugin API

Related topics

File

core/lib/Drupal/Core/Render/Element/ElementInterface.php, line 30

Namespace

Drupal\Core\Render\Element
View 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

Title Sort descending Modifiers Object type Summary Overrides
ElementInterface::getInfo public function Returns the element properties for this element. 56
ElementInterface::setAttributes public static function Sets a form element's class attribute. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 6
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.