You are here

public function ContentReportSettingsForm::buildForm in Open Social 8.6

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_content_report/src/Form/ContentReportSettingsForm.php \Drupal\social_content_report\Form\ContentReportSettingsForm::buildForm()
  2. 8.5 modules/social_features/social_content_report/src/Form/ContentReportSettingsForm.php \Drupal\social_content_report\Form\ContentReportSettingsForm::buildForm()
  3. 8.7 modules/social_features/social_content_report/src/Form/ContentReportSettingsForm.php \Drupal\social_content_report\Form\ContentReportSettingsForm::buildForm()
  4. 8.8 modules/social_features/social_content_report/src/Form/ContentReportSettingsForm.php \Drupal\social_content_report\Form\ContentReportSettingsForm::buildForm()
  5. 10.3.x modules/social_features/social_content_report/src/Form/ContentReportSettingsForm.php \Drupal\social_content_report\Form\ContentReportSettingsForm::buildForm()
  6. 10.0.x modules/social_features/social_content_report/src/Form/ContentReportSettingsForm.php \Drupal\social_content_report\Form\ContentReportSettingsForm::buildForm()
  7. 10.1.x modules/social_features/social_content_report/src/Form/ContentReportSettingsForm.php \Drupal\social_content_report\Form\ContentReportSettingsForm::buildForm()
  8. 10.2.x modules/social_features/social_content_report/src/Form/ContentReportSettingsForm.php \Drupal\social_content_report\Form\ContentReportSettingsForm::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_content_report/src/Form/ContentReportSettingsForm.php, line 67

Class

ContentReportSettingsForm
Class EventSettingsForm.

Namespace

Drupal\social_content_report\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this->configFactory
    ->get('social_content_report.settings');

  // Allow immediate unpublishing.
  $form['unpublish_threshold'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Unpublished immediately'),
    '#description' => $this
      ->t('Whether the content is immediately unpublished if a user reports it as inappropriate.'),
    '#default_value' => $config
      ->get('unpublish_threshold'),
  ];

  // A list of reason terms to display the reason textfield for.
  $terms = $this->entityTypeManager
    ->getStorage('taxonomy_term')
    ->loadTree('report_reasons');
  foreach ($terms as $term) {
    $reason_terms[$term->tid] = $term->name;
  }
  $form['reasons_with_text'] = [
    '#type' => 'checkboxes',
    '#options' => $reason_terms,
    '#title' => $this
      ->t('Terms with additional reason text'),
    '#description' => $this
      ->t('Select the terms that will show an additional field where users can describe their reasons.'),
    '#default_value' => $config
      ->get('reasons_with_text'),
  ];

  // Make reason text at reporting mandatory.
  $form['mandatory_reason'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Mandatory reason text'),
    '#description' => $this
      ->t('Whether users should fill in a mandatory reason or if it is optional.'),
    '#default_value' => $config
      ->get('mandatory_reason'),
  ];
  return parent::buildForm($form, $form_state);
}