You are here

public function RevisionLogWidget::settingsForm in Hide Revision Field 8.2

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. 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 definition for the widget settings.

Overrides StringTextareaWidget::settingsForm

File

src/Plugin/Field/FieldWidget/RevisionLogWidget.php, line 91

Class

RevisionLogWidget
Plugin implementation of the 'hide_revision_field_log_widget' widget.

Namespace

Drupal\hide_revision_field\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  $settings = $this
    ->getSettings();
  $element['show'] = [
    '#type' => 'checkbox',
    '#title' => t('Show'),
    '#default_value' => $settings['show'],
    '#description' => $this
      ->t('Show field by default.'),
  ];
  $element['allow_user_settings'] = [
    '#type' => 'checkbox',
    '#title' => t('Allow user specific configuration.'),
    '#default_value' => $settings['allow_user_settings'],
    '#description' => $this
      ->t('Allow users to configure their own default value/display of the revision log field on their profile pages.'),
  ];
  $element['permission_based'] = [
    '#type' => 'checkbox',
    '#title' => t('Display Based on Permissions'),
    '#default_value' => $settings['permission_based'],
    '#description' => $this
      ->t('Show field if user has permission "%perm: Customize revision logs".', [
      '%perm' => $this->fieldDefinition
        ->getTargetEntityTypeId(),
    ]),
  ];
  $element['default'] = [
    '#type' => 'textfield',
    '#title' => t('Default'),
    '#default_value' => $settings['default'],
    '#description' => $this
      ->t('Default value for revision log.'),
  ];
  return $element;
}