public function SocialProfileFieldsSettingsForm::buildForm in Open Social 8.4
Same name and namespace in other branches
- 8.9 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 8.2 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 8.3 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 8.5 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 8.6 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 8.7 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 8.8 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 10.3.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 10.0.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 10.1.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
- 10.2.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- modules/
social_features/ social_profile/ modules/ social_profile_fields/ src/ Form/ SocialProfileFieldsSettingsForm.php, line 101
Class
- SocialProfileFieldsSettingsForm
- Configure social profile settings.
Namespace
Drupal\social_profile_fields\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('social_profile_fields.settings');
// Add an introduction text to explain what can be done here.
$form['introduction']['description'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this
->t('Per profile type you can choose which fields you want to use. Users will not be able to edit or view fields that are deselected.'),
];
$form['introduction']['warning'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this
->t('Be aware that data is <em>not removed</em>, and can possibly still be found through the search, until you flush the data.'),
];
/** @var \Drupal\profile\Entity\ProfileType $profile_type */
foreach (ProfileType::loadMultiple() as $profile_type) {
$type = $profile_type
->id();
$form[$type] = [
'#type' => 'details',
'#title' => $this
->t('Settings for profiletype: @profile_type', [
'@profile_type' => $type,
]),
'#description' => $this
->t('Select the fields you want to use on this profile type.'),
'#open' => TRUE,
];
/** @var \Drupal\field\Entity\FieldConfig $field_config */
foreach ($this->profileFieldsHelper
->getProfileFields($type) as $field) {
// Loop through the fields.
$id = $field['id'];
// Hiding this field on the Open Social profile will make no difference,
// let's skip it for now.
if ($type === 'profile' && $id === 'profile_profile_field_profile_show_email') {
continue;
}
// No setting is TRUE.
$default_value = is_null($config
->get($id)) ? TRUE : $config
->get($id);
$form[$type][$id] = [
'#type' => 'checkbox',
'#title' => $field['label'],
'#description' => $field['name'],
'#default_value' => $default_value,
];
}
}
$form['actions']['social_profile_fields_confirm_flush'] = [
'#type' => 'submit',
'#submit' => [
'::submitFlush',
],
'#value' => $this
->t('Flush profile data'),
'#weight' => 5,
];
return parent::buildForm($form, $form_state);
}