public function SettingsForm::buildForm in Sidr: Accessible Mobile Menus 8.3
Same name and namespace in other branches
- 8 src/Form/SettingsForm.php \Drupal\sidr\Form\SettingsForm::buildForm()
- 8.2 src/Form/SettingsForm.php \Drupal\sidr\Form\SettingsForm::buildForm()
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/ SettingsForm.php, line 32
Class
- SettingsForm
- Global sidr settings form.
Namespace
Drupal\sidr\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('sidr.settings');
$form['sidr_theme'] = [
'#type' => 'select',
'#title' => $this
->t('Sidr theme'),
'#description' => $this
->t('If you want to style Sidr with your own CSS, choose %bare', [
'%bare' => $this
->t('Bare'),
]),
'#default_value' => $config
->get('sidr_theme') ?: 'bare',
'#options' => [
'bare' => $this
->t('Bare'),
'light' => $this
->t('Light'),
'dark' => $this
->t('Dark'),
],
];
$form['close_on_escape'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Close on Escape'),
'#description' => $this
->t('Close Sidr panels when the user presses the Escape key.'),
'#default_value' => $config
->get('close_on_escape'),
];
$form['close_on_blur'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Close on blur'),
'#description' => $this
->t('Close Sidr panels when the user interacts with outside elements.'),
'#default_value' => $config
->get('close_on_blur'),
];
return parent::buildForm($form, $form_state);
}