public function StylesFilterConfigForm::buildForm in Bootstrap Styles 1.0.x
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ StylesFilterConfigForm.php, line 60
Class
- StylesFilterConfigForm
- Configure and filter styles' plugins.
Namespace
Drupal\bootstrap_styles\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config(static::CONFIG);
$form['styles_groups'] = [
'#type' => 'container',
'#tree' => TRUE,
];
foreach ($this->stylesGroupManager
->getStylesGroups() as $group_key => $style_group) {
// Styles Group.
if (isset($style_group['styles'])) {
$form['styles_groups'][$group_key] = [
'#type' => 'details',
'#title' => $style_group['title']
->__toString(),
'#open' => TRUE,
'#tree' => TRUE,
];
foreach ($style_group['styles'] as $style_key => $style) {
$config_key = 'plugins.' . $group_key . '.' . $style_key . '.enabled';
$form['styles_groups'][$group_key][$style_key]['enabled'] = [
'#type' => 'checkbox',
'#title' => $style['title']
->__toString(),
'#default_value' => $config
->get($config_key),
];
}
}
}
return parent::buildForm($form, $form_state);
}