You are here

public function SocialTaggingSettingsForm::buildForm in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  2. 8 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  3. 8.2 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  4. 8.3 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  5. 8.4 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  6. 8.5 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  7. 8.6 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  8. 8.7 modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  9. 10.3.x modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  10. 10.0.x modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  11. 10.1.x modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php \Drupal\social_tagging\Form\SocialTaggingSettingsForm::buildForm()
  12. 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\Form

Code

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);
}