You are here

protected function EntityBrowser::handleForm in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/display/EntityBrowser.php \Drupal\entity_browser\Plugin\views\display\EntityBrowser::handleForm()

Handles form elements on a view.

Parameters

array $render: Rendered content.

1 call to EntityBrowser::handleForm()
EntityBrowser::execute in src/Plugin/views/display/EntityBrowser.php
Executes the view and returns data in the format required.

File

src/Plugin/views/display/EntityBrowser.php, line 152

Class

EntityBrowser
The plugin that handles entity browser display.

Namespace

Drupal\entity_browser\Plugin\views\display

Code

protected function handleForm(array &$render) {
  if (!empty($this->view->field['entity_browser_select'])) {

    /** @var \Drupal\entity_browser\Plugin\views\field\SelectForm $select */
    $select = $this->view->field['entity_browser_select'];
    $select
      ->viewsForm($render);
    $render['#post_render'][] = [
      get_class($this),
      'postRender',
    ];
    $substitutions = [];
    foreach ($this->view->result as $row) {
      $form_element_row_id = $select
        ->getRowId($row);
      $substitutions[] = [
        'placeholder' => '<!--form-item-entity_browser_select--' . $form_element_row_id . '-->',
        'field_name' => 'entity_browser_select',
        'row_id' => $form_element_row_id,
      ];
    }
    $render['#substitutions'] = [
      '#type' => 'value',
      '#value' => $substitutions,
    ];
  }
}