class RenderElementHelper
Same name in other branches
- 9 core/modules/inline_form_errors/src/RenderElementHelper.php \Drupal\inline_form_errors\RenderElementHelper
- 10 core/modules/inline_form_errors/src/RenderElementHelper.php \Drupal\inline_form_errors\RenderElementHelper
- 11.x core/modules/inline_form_errors/src/RenderElementHelper.php \Drupal\inline_form_errors\RenderElementHelper
Provides functionality to process render elements.
Hierarchy
- class \Drupal\inline_form_errors\RenderElementHelper
Expanded class hierarchy of RenderElementHelper
1 file declares its use of RenderElementHelper
- inline_form_errors.module in core/
modules/ inline_form_errors/ inline_form_errors.module - Enables inline form errors.
File
-
core/
modules/ inline_form_errors/ src/ RenderElementHelper.php, line 10
Namespace
Drupal\inline_form_errorsView source
class RenderElementHelper {
/**
* Alters the element type info.
*
* @param array $info
* An associative array with structure identical to that of the return value
* of \Drupal\Core\Render\ElementInfoManagerInterface::getInfo().
*/
public function alterElementInfo(array &$info) {
foreach ($info as $element_type => $element_info) {
$info[$element_type]['#process'][] = [
static::class,
'processElement',
];
}
}
/**
* Process all render elements.
*
* @param array $element
* An associative array containing the properties and children of the
* element. Note that $element must be taken by reference here, so processed
* child elements are taken over into $form_state.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
* @param array $complete_form
* The complete form structure.
*
* @return array
* The processed element.
*/
public static function processElement(array &$element, FormStateInterface $form_state, array &$complete_form) {
// Prevent displaying inline form errors when disabled for the whole form.
if (!empty($complete_form['#disable_inline_form_errors'])) {
$element['#error_no_message'] = TRUE;
}
return $element;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
RenderElementHelper::alterElementInfo | public | function | Alters the element type info. |
RenderElementHelper::processElement | public static | function | Process all render elements. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.