diff --git a/modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php b/modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php index b58c72f85bf..072e4e3da23 100644 --- a/modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php +++ b/modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php @@ -219,16 +219,29 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => is_null($config->get('profile_address_field_administrative_area')) ? TRUE : $config->get('profile_address_field_administrative_area'), ]; } + + if ($type === 'profile' && $id === 'profile_profile_field_profile_nick_name') { + $form[$type]['profile_profile_nickname_wrapper']['nickname_settings'] = [ + '#type' => 'details', + '#title' => $this->t('Nickname field settings'), + '#open' => TRUE, + '#states' => [ + 'visible' => [ + ':input[name="' . $id . '"]' => ['checked' => TRUE], + ], + ], + ]; + + $form[$type]['profile_profile_nickname_wrapper']['nickname_settings']['nickname_unique_validation'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Unique nicknames'), + '#description' => $this->t('If you check this, validation is applied that verifies the users nickname is unique whenever they save their profile.'), + '#default_value' => $config->get('nickname_unique_validation'), + ]; + } } } - $form['nickname_unique_validation'] = [ - '#type' => 'checkbox', - '#title' => $this->t('Unique nicknames'), - '#description' => $this->t('If you check this, validation is applied that verifies the users nickname is unique whenever they save their profile.'), - '#default_value' => $config->get('nickname_unique_validation'), - ]; - $form['actions']['social_profile_fields_confirm_flush'] = [ '#type' => 'submit', '#submit' => ['::submitFlush'], @@ -262,7 +275,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $config->set('profile_address_field_postalcode', $main_address_value ? $form_state->getValue('profile_address_field_postalcode') : FALSE); $config->set('profile_address_field_administrative_area', $main_address_value ? $form_state->getValue('profile_address_field_administrative_area') : FALSE); - $config->set('nickname_unique_validation', $form_state->getValue('nickname_unique_validation')); + $nickname_unique_validation = $form_state->getValue('profile_profile_field_profile_nick_name') ? $form_state->getValue('nickname_unique_validation') : FALSE; + $config->set('nickname_unique_validation', $nickname_unique_validation); $config->save(); parent::submitForm($form, $form_state);