public function TokenVarConfig::submitForm in Token Variable 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 ConfigFormBase::submitForm
File
- src/
Form/ TokenVarConfig.php, line 65
Class
- TokenVarConfig
- Implements TokenVarConfig class.
Namespace
Drupal\token_var\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues()['token_var'];
$config = $this
->config('token_var.settings');
$enabled_vars = array();
foreach ($values as $name => $data) {
$name = str_replace('.', '|', $name);
foreach ($data as $key => $value) {
if ($value) {
$enabled_vars[$name][$key] = $value;
}
}
}
$config
->set('token_var_replacements', $enabled_vars)
->save();
token_clear_cache();
parent::submitForm($form, $form_state);
}