public function SettingsForm::buildForm in Christmas Lights 8
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 31
Class
- SettingsForm
- Defines a form that configures christmas_lights settings.
Namespace
Drupal\christmas_lights\FormCode
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
$config = $this
->config('christmas_lights.settings');
$form['enabled'] = [
'#type' => 'checkbox',
'#default_value' => $config
->get('enabled'),
'#title' => $this
->t('Enable christmas lights'),
];
$form['start'] = [
'#type' => 'date',
'#title' => $this
->t('Start date'),
'#default_value' => date('Y-m-d', $config
->get('start')),
'#description' => $this
->t('The date your enable christmas lights'),
'#required' => TRUE,
];
$form['end'] = [
'#type' => 'date',
'#title' => $this
->t('Finish date'),
'#default_value' => date('Y-m-d', $config
->get('end')),
'#description' => $this
->t('The date your disable christmas lights'),
'#required' => TRUE,
];
return parent::buildForm($form, $form_state);
}