public function AddForm::submitForm in Custom Meta 2.0.x
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/ AddForm.php, line 93
Class
- AddForm
- Provides the custom meta tag add form.
Namespace
Drupal\custom_meta\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $this
->config('custom_meta.settings')
->get('tag');
$values[$form_state
->getValue('name')] = [
'attribute' => $form_state
->getValue('attribute'),
'name' => $form_state
->getValue('name'),
'label' => $form_state
->getValue('label'),
'description' => $form_state
->getValue('description'),
];
$this
->configFactory()
->getEditable('custom_meta.settings')
->set('tag', $values)
->save();
\Drupal::messenger()
->addStatus('Meta tag has been saved.');
$form_state
->setRedirect('custom_meta.admin_overview');
}