public function ViewportSettingsForm::submitForm in Viewport 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/ ViewportSettingsForm.php, line 119
Class
- ViewportSettingsForm
- Class to configure viewport settings for this site.
Namespace
Drupal\viewport\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$viewportSettings = $this
->configFactory()
->getEditable('viewport.settings');
// Store submitted values.
foreach ($form_state
->getValues() as $key => $value) {
if (in_array($key, Element::children($form['viewport']))) {
// Make sure user_scalable is treated as a boolean.
$value = $key == 'user_scalable' ? (bool) $value : $value;
$viewportSettings
->set($key, $value);
}
}
$viewportSettings
->save();
}