public function ConfigEditor::submitForm in Devel 8.3
Same name and namespace in other branches
- 8 src/Form/ConfigEditor.php \Drupal\devel\Form\ConfigEditor::submitForm()
- 8.2 src/Form/ConfigEditor.php \Drupal\devel\Form\ConfigEditor::submitForm()
- 4.x src/Form/ConfigEditor.php \Drupal\devel\Form\ConfigEditor::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 FormInterface::submitForm
File
- src/
Form/ ConfigEditor.php, line 119
Class
- ConfigEditor
- Edit config variable form.
Namespace
Drupal\devel\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
try {
$this
->configFactory()
->getEditable($values['name'])
->setData($values['parsed_value'])
->save();
$this
->messenger()
->addMessage($this
->t('Configuration variable %variable was successfully saved.', [
'%variable' => $values['name'],
]));
$this
->logger('devel')
->info('Configuration variable %variable was successfully saved.', [
'%variable' => $values['name'],
]);
$form_state
->setRedirectUrl(Url::fromRoute('devel.configs_list'));
} catch (\Exception $e) {
$this
->messenger()
->addError($e
->getMessage());
$this
->logger('devel')
->error('Error saving configuration variable %variable : %error.', [
'%variable' => $values['name'],
'%error' => $e
->getMessage(),
]);
}
}