You are here

public function View::buildConfigurationForm in Entity Browser 8

Same name in this branch
  1. 8 src/Plugin/EntityBrowser/Widget/View.php \Drupal\entity_browser\Plugin\EntityBrowser\Widget\View::buildConfigurationForm()
  2. 8 src/Plugin/EntityBrowser/SelectionDisplay/View.php \Drupal\entity_browser\Plugin\EntityBrowser\SelectionDisplay\View::buildConfigurationForm()
Same name and namespace in other branches
  1. 8.2 src/Plugin/EntityBrowser/SelectionDisplay/View.php \Drupal\entity_browser\Plugin\EntityBrowser\SelectionDisplay\View::buildConfigurationForm()

Implements PluginFormInterface::buildConfigurationForm().

Overrides PluginConfigurationFormTrait::buildConfigurationForm

File

src/Plugin/EntityBrowser/SelectionDisplay/View.php, line 86

Class

View
Displays current selection in a View.

Namespace

Drupal\entity_browser\Plugin\EntityBrowser\SelectionDisplay

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $options = [];

  // Get all views displays.
  $views = Views::getAllViews();
  foreach ($views as $view_id => $view) {
    foreach ($view
      ->get('display') as $display_id => $display) {
      $options[$view_id . '.' . $display_id] = $this
        ->t('@view : @display', [
        '@view' => $view
          ->label(),
        '@display' => $display['display_title'],
      ]);
    }
  }
  $form['view'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('View : View display'),
    '#default_value' => $this->configuration['view'] . '.' . $this->configuration['view_display'],
    '#options' => $options,
    '#required' => TRUE,
    '#description' => $this
      ->t('View display to use for displaying currently selected items. Do note that to get something useful out of this display, its first contextual filter should be a filter on the primary identifier field of your entity type (e.g., Node ID, Media ID).'),
  ];
  return $form;
}