Repository URL to install this package:
|
Version:
1.2.26 ▾
|
<?php
namespace Drupal\custom_forms\Element;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\RenderElement;
use Drupal\Core\Template\Attribute;
/**
* Class InfoElement
*
* @package Drupal\custom_forms\Element
*
* @RenderElement("info_element")
*/
class InfoElement extends RenderElement {
/**
* {@inheritdoc}
*/
public function getInfo() {
return [
'#theme' => 'field_info',
'#input' => FALSE,
'#pre_render' => [
[__CLASS__, 'preRenderInfoElement'],
],
'#title_display' => 'invisible',
'#icon' => NULL,
'#message' => NULL,
'#weight' => 1000
];
}
public static function preRenderInfoElement(array $element) : array {
$attributes = new Attribute();
$attributes->addClass('field-info');
$icon_attributes = new Attribute();
$icon_attributes->addClass('icon');
$message_attributes = new Attribute();
$message_attributes->addClass('message');
$element['#attributes'] = $attributes;
$element['#icon_attributes'] = $icon_attributes;
$element['#message_attributes'] = $message_attributes;
return $element;
}
}