public function AddToHeadProfileForm::submitForm in Add To Head 8
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 FormInterface::submitForm
File
- src/
Form/ AddToHeadProfileForm.php, line 136
Class
Namespace
Drupal\add_to_head\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$settings = \Drupal::config('add_to_head.settings')
->get('add_to_head_profiles');
if ($form_state
->getValue('name') != $form_state
->getValue('name_orig')) {
unset($settings[$form_state
->getValue('name_orig')]);
}
$settings[$form_state
->getValue('name')] = array(
'name' => $form_state
->getValue('name'),
'code' => trim($form_state
->getValue('code')),
'scope' => $form_state
->getValue('scope'),
'paths' => [
'visibility' => $form_state
->getValue('paths')['visibility'],
'paths' => trim($form_state
->getValue('paths')['paths']),
],
'roles' => [
'visibility' => $form_state
->getValue('roles')['visibility'],
'list' => array_filter($form_state
->getValue('roles')['list']),
],
);
add_to_head_set_settings($settings);
$form_state
->setRedirect('add_to_head.admin');
}