function ContentTranslationFormHooks::userAccountSettingsFormAlter
Same name and namespace in other branches
- 11.x core/modules/content_translation/src/Hook/ContentTranslationFormHooks.php \Drupal\content_translation\Hook\ContentTranslationFormHooks::userAccountSettingsFormAlter()
Implements hook_form_FORM_ID_alter() for 'user_admin_settings' form.
Attributes
#[Hook('form_user_admin_settings_alter')]
File
-
core/
modules/ content_translation/ src/ Hook/ ContentTranslationFormHooks.php, line 112
Class
- ContentTranslationFormHooks
- Form hook implementations for content_translation.
Namespace
Drupal\content_translation\HookCode
public function userAccountSettingsFormAlter(array &$form, FormStateInterface $form_state) : void {
// Insert the new element just after 'anonymous_settings'.
$index = array_search('anonymous_settings', array_keys($form));
$form = array_slice($form, 0, $index + 1) + [
'language' => [
'#type' => 'details',
'#title' => $this->t('Language settings'),
'#open' => TRUE,
'#tree' => TRUE,
],
] + $form;
$form_state->set([
'content_translation',
'key',
], 'language');
$form['language'] += $this->contentTranslationWidget
->getWidget('user', 'user', $form, $form_state);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.