You are here

public function CommentPostFormatter::settingsForm in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  2. 8 modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  3. 8.2 modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  4. 8.3 modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  5. 8.5 modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  6. 8.6 modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  7. 8.7 modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  8. 8.8 modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  9. 10.3.x modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  10. 10.0.x modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  11. 10.1.x modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()
  12. 10.2.x modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php \Drupal\social_post\Plugin\Field\FieldFormatter\CommentPostFormatter::settingsForm()

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form elements for the formatter settings.

Overrides CommentDefaultFormatter::settingsForm

File

modules/social_features/social_post/src/Plugin/Field/FieldFormatter/CommentPostFormatter.php, line 155

Class

CommentPostFormatter
Provides a post comment formatter.

Namespace

Drupal\social_post\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = [];
  $element['num_comments'] = [
    '#type' => 'number',
    '#min' => 0,
    '#max' => 10,
    '#title' => $this
      ->t('Number of comments'),
    '#default_value' => $this
      ->getSetting('num_comments'),
  ];
  $orders = [
    'ASC' => $this
      ->t('Oldest first'),
    'DESC' => $this
      ->t('Newest first'),
  ];
  $element['order'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Order'),
    '#description' => $this
      ->t('Select the order used to show the list of comments.'),
    '#default_value' => $this
      ->getSetting('order'),
    '#options' => $orders,
  ];
  return $element;
}