public function SocialTaggingSettingsForm::buildForm in Open Social 8.4
Same name and namespace in other branches
- 8.9 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 8 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 8.2 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 8.3 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 8.5 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 8.6 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 8.7 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 8.8 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 10.3.x modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 10.0.x modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 10.1.x modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
- 10.2.x modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::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_tagging/ src/ Form/ SocialTaggingSettingsForm.php, line 63
Class
- SocialTaggingSettingsForm
- Class SocialTaggingSettingsForm.
Namespace
Drupal\social_tagging\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Get the configuration file.
$config = $this
->config('social_tagging.settings');
$content_types = [];
foreach (NodeType::loadMultiple() as $node_type) {
/* @var NodeType $node_type */
$content_types[] = $node_type
->get('name');
}
$form['enable_content_tagging'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Allow users to tag content in content.'),
'#default_value' => $config
->get('enable_content_tagging'),
'#required' => FALSE,
'#description' => $this
->t("Determine whether users are allowed to tag content, view tags and filter on tags in content. (@content)", [
'@content' => implode(', ', $content_types),
]),
];
$form['allow_category_split'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Allow category split.'),
'#default_value' => $config
->get('allow_category_split'),
'#required' => FALSE,
'#description' => $this
->t("Determine if the main categories of the vocabury will be used as seperate tag fields or as a single tag field when using tags on content."),
];
$form['node_type_settings'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Type configuration'),
];
$form['node_type_settings']['tag_type_group'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Group'),
'#default_value' => $config
->get('tag_type_group'),
'#required' => FALSE,
];
/** @var \Drupal\node\Entity\NodeType $nodetype */
foreach (NodeType::loadMultiple() as $nodetype) {
$field_name = 'tag_node_type_' . $nodetype
->id();
$value = $config
->get($field_name);
$default_value = isset($value) ? $config
->get($field_name) : TRUE;
$form['node_type_settings'][$field_name] = [
'#type' => 'checkbox',
'#title' => $nodetype
->label(),
'#default_value' => $default_value,
'#required' => FALSE,
];
}
$form['some_text_field']['#markup'] = '<p><strong>' . Link::createFromRoute($this
->t('Click here to go to the social tagging overview'), 'entity.taxonomy_vocabulary.overview_form', [
'taxonomy_vocabulary' => 'social_tagging',
])
->toString() . '</strong></p>';
return parent::buildForm($form, $form_state);
}