You are here

public function AgreementEntity::buildOptionsForm in Agreement 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/field/AgreementEntity.php \Drupal\agreement\Plugin\views\field\AgreementEntity::buildOptionsForm()

Default options form that provides the label widget that all fields should have.

Overrides FieldPluginBase::buildOptionsForm

File

src/Plugin/views/field/AgreementEntity.php, line 61

Class

AgreementEntity
Provides a field handler for agreement configuration entities.

Namespace

Drupal\agreement\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $display_options = [
    'id' => $this
      ->t('ID'),
    'label' => $this
      ->t('Label'),
    'path' => $this
      ->t('Path'),
    'roles' => $this
      ->t('Roles'),
    'title' => $this
      ->t('Page Title'),
  ];
  $default_options = [];
  foreach ($display_options as $name => $value) {
    $default_options[$name] = in_array($name, $this->options['display']) ? $name : 0;
  }
  $form['display'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Display'),
    '#description' => $this
      ->t('Choose the agreement options to display.'),
    '#options' => $display_options,
    '#default_value' => $default_options,
  ];
  return $form;
}