public function Fz152ContactSettings::buildForm in FZ152 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
- modules/
contact/ src/ Form/ Fz152ContactSettings.php, line 64
Class
- Fz152ContactSettings
- Configure example settings for this site.
Namespace
Drupal\fz152_contact\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$contact_bundles = $this
->getContactBundles();
foreach ($contact_bundles as $bundle_name => $bundle_info) {
$config = $this
->config("fz152_contact.settings.{$bundle_name}");
$form['contact_' . $bundle_name . '_enable'] = [
'#type' => 'checkbox',
'#title' => $bundle_info['label'] . " ({$bundle_name})",
'#default_value' => $config
->get('enabled'),
];
$form['contact_' . $bundle_name . '_weight'] = [
'#type' => 'number',
'#title' => 'Weight of element',
'#default_value' => $config
->get('weight'),
'#states' => [
'visible' => [
'input[name="contact_' . $bundle_name . '_enable"]' => [
'checked' => TRUE,
],
],
],
];
}
return parent::buildForm($form, $form_state);
}