function public function SettingBase::getGroupElement
8.x-3.x SettingBase.php | public SettingBase::getGroupElement(Element $form, FormStateInterface $form_state) |
Retrieves the group form element the setting belongs to.
Parameters
\Drupal\bootstrap\Utility\Element $form: The Element object that comprises the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\bootstrap\Utility\Element The group element object.
Overrides SettingInterface::getGroupElement
Class
- SettingBase
- Base class for a setting.
Namespace
Drupal\bootstrap\Plugin\SettingSource src/Plugin/Setting/SettingBase.php (line 120)
public function getGroupElement(Element $form, FormStateInterface $form_state) {
$groups = $this->getGroups();
$group = $form;
$first = TRUE;
foreach ($groups as $key => $title) {
if (!isset($group->$key)) {
if ($title) {
$group->$key = ['#type' => 'details', '#title' => $title];
}
else {
$group->$key = ['#type' => 'container'];
}
$group = Element::create($group->$key->getArray(), $form_state);
if ($first) {
$group->setProperty('group', 'bootstrap');
}
else {
$group->setProperty('open', FALSE);
}
}
else {
$group = Element::create($group->$key->getArray(), $form_state);
}
$first = FALSE;
}
return $group;
}