예제 #1
0
 /**
  * {@inheritdoc}
  */
 public static function processElement(Element $element, FormStateInterface $form_state, array &$complete_form)
 {
     $dropbuttons = Element::create();
     foreach ($element->children(TRUE) as $key => $child) {
         if ($dropbutton = $child->getProperty('dropbutton')) {
             // If there is no dropbutton for this button group yet, create one.
             if (!isset($dropbuttons->{$dropbutton})) {
                 $dropbuttons->{$dropbutton} = ['#type' => 'dropbutton'];
             }
             $dropbuttons[$dropbutton]['#links'][$key] = $child->getArray();
             // Remove original child from the element so it's not rendered twice.
             $child->setProperty('printed', TRUE);
         }
     }
     $element->exchangeArray($dropbuttons->getArray() + $element->getArray());
 }