You are here

public function ContentBrowserPreview::buildOptionsForm in Content Browser 8

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

Overrides FieldPluginBase::buildOptionsForm

File

src/Plugin/views/field/ContentBrowserPreview.php, line 112

Class

ContentBrowserPreview
Defines a custom field that renders a preview of a Content Entity type, and allows for changing field settings with exposed input.

Namespace

Drupal\content_browser\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  $form['view_mode'] = [
    '#title' => $this
      ->t('Content view mode'),
    '#options' => $this->entityDisplayRepository
      ->getViewModeOptions($this
      ->getEntityType()),
    '#type' => 'select',
    '#default_value' => $this->options['view_mode'],
    '#description' => $this
      ->t('The view mode which you would like the content to be previewed in.'),
    '#weight' => -105,
  ];
  $form['exposed_view_mode'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Exposed view mode'),
    '#default_value' => $this->options['exposed_view_mode'],
    '#description' => $this
      ->t('If checked, the option to switch view modes will be exposed to the user.'),
    '#weight' => -104,
  ];
}