'checkboxes',
'#title' => 'Checkboxes',
'#options' => [
0 => 'Zero',
'foo' => 'Foo',
1 => 'One',
'bar' => $this->t('Bar - checkboxes'),
'>' => "Special Char",
],
];
if ($customize) {
$form['checkboxes'] += [
'foo' => [
'#description' => 'Enable to foo.',
],
1 => [
'#weight' => 10,
],
];
}
// Expand #type radios, setting custom element properties for some but not
// all options.
$form['radios'] = [
'#type' => 'radios',
'#title' => 'Radios',
'#options' => [
0 => 'Zero',
'foo' => 'Foo',
1 => 'One',
'bar' => 'Bar - radios',
'>' => "Special Char",
],
];
if ($customize) {
$form['radios'] += [
'foo' => [
'#description' => 'Enable to foo.',
],
1 => [
'#weight' => 10,
],
];
}
$form['submit'] = ['#type' => 'submit', '#value' => 'Submit'];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state->setResponse(new JsonResponse($form_state->getValues()));
}
}