public function FrontPageSettingsForm::submitForm in Front Page 8
Same name and namespace in other branches
- 9.1.x src/Form/FrontPageSettingsForm.php \Drupal\front_page\Form\FrontPageSettingsForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ConfigFormBase::submitForm
File
- src/
Form/ FrontPageSettingsForm.php, line 109
Class
- FrontPageSettingsForm
- Configure site information settings for this site.
Namespace
Drupal\front_page\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = \Drupal::configFactory()
->getEditable('front_page.settings');
// Set if all config are enabled or not.
$config
->set('enable', $form_state
->getValue('front_page_enable'));
// Set config by role.
$rolesList = $form_state
->getUserInput()['roles'];
if (is_array($rolesList)) {
foreach ($rolesList as $rid => $role) {
$config
->set('rid_' . $rid, $role);
}
}
$config
->save();
parent::submitForm($form, $form_state);
}