Added another front page space for Yaffs info. Added roave security for composer.
[yaffs-website] / web / core / lib / Drupal / Core / Render / Element / CompositeFormElementTrait.php
1 <?php
2
3 namespace Drupal\Core\Render\Element;
4
5 /**
6  * Provides a trait for radios, checkboxes, and similar composite form elements.
7  *
8  * Any form element that is comprised of several distinct parts can use this
9  * trait to add support for a composite title or description.
10  */
11 trait CompositeFormElementTrait {
12
13   /**
14    * Adds form element theming to an element if its title or description is set.
15    *
16    * This is used as a pre render function for checkboxes and radios.
17    */
18   public static function preRenderCompositeFormElement($element) {
19     // Set the element's title attribute to show #title as a tooltip, if needed.
20     if (isset($element['#title']) && $element['#title_display'] == 'attribute') {
21       $element['#attributes']['title'] = $element['#title'];
22       if (!empty($element['#required'])) {
23         // Append an indication that this field is required.
24         $element['#attributes']['title'] .= ' (' . t('Required') . ')';
25       }
26     }
27
28     if (isset($element['#title']) || isset($element['#description'])) {
29       // @see #type 'fieldgroup'
30       $element['#attributes']['id'] = $element['#id'] . '--wrapper';
31       $element['#theme_wrappers'][] = 'fieldset';
32       $element['#attributes']['class'][] = 'fieldgroup';
33       $element['#attributes']['class'][] = 'form-composite';
34     }
35     return $element;
36   }
37
38 }