function FormHooks::userFormSubmit
Same name and namespace in other branches
- main core/themes/admin/src/Hook/FormHooks.php \Drupal\admin\Hook\FormHooks::userFormSubmit()
Submit handler for the user form.
File
-
core/
themes/ admin/ src/ Hook/ FormHooks.php, line 484
Class
- FormHooks
- Provides form related hook implementations.
Namespace
Drupal\admin\HookCode
public static function userFormSubmit(array &$form, FormStateInterface $form_state) : void {
/** @var \Drupal\Core\Session\AccountInterface $account */
$account = $form_state->getBuildInfo()['callback_object']
->getEntity();
$settings = \Drupal::classResolver(Settings::class);
$enabledUserOverrides = $form_state->getValue('enable_user_settings');
if ($enabledUserOverrides) {
$user_settings = [
'preset_accent_color' => $form_state->getValue('preset_accent_color'),
'preset_focus_color' => $form_state->getValue('preset_focus_color'),
'enable_dark_mode' => $form_state->getValue('enable_dark_mode'),
'high_contrast_mode' => (bool) $form_state->getValue('high_contrast_mode'),
'accent_color' => $form_state->getValue('accent_color'),
'focus_color' => $form_state->getValue('focus_color'),
'layout_density' => $form_state->getValue('layout_density'),
'show_description_toggle' => $form_state->getValue('show_description_toggle'),
];
$settings->setAll($user_settings, $account);
}
else {
$settings->clear($account);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.