You are here

interface ElementInterface in Drupal 10

Same name in this branch
  1. 10 core/modules/config_translation/src/FormElement/ElementInterface.php \Drupal\config_translation\FormElement\ElementInterface
  2. 10 core/lib/Drupal/Core/Render/Element/ElementInterface.php \Drupal\Core\Render\Element\ElementInterface
Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Render/Element/ElementInterface.php \Drupal\Core\Render\Element\ElementInterface
  2. 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

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

Namesort descending Modifiers Type Description 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. 1
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 1