You are here

protected function PullForm::buildChannelSelect in Entity Share 8.3

Same name and namespace in other branches
  1. 8 modules/entity_share_client/src/Form/PullForm.php \Drupal\entity_share_client\Form\PullForm::buildChannelSelect()
  2. 8.2 modules/entity_share_client/src/Form/PullForm.php \Drupal\entity_share_client\Form\PullForm::buildChannelSelect()

Helper function to generate channel select.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state object.

1 call to PullForm::buildChannelSelect()
PullForm::buildForm in modules/entity_share_client/src/Form/PullForm.php
Form constructor.

File

modules/entity_share_client/src/Form/PullForm.php, line 437

Class

PullForm
Form controller to pull entities.

Namespace

Drupal\entity_share_client\Form

Code

protected function buildChannelSelect(array &$form, FormStateInterface $form_state) {
  $selected_remote_id = $form_state
    ->getValue('remote', $this->query
    ->get('remote'));

  // No remote selected.
  if (empty($this->remoteWebsites[$selected_remote_id])) {
    return;
  }
  $selected_remote = $this->remoteWebsites[$selected_remote_id];
  $this->channelsInfos = $this->remoteManager
    ->getChannelsInfos($selected_remote);
  $select_element = $this
    ->buildSelectElement($form_state, 'channel');
  if ($select_element) {
    $select_element['#title'] = $this
      ->t('Channel');
    $select_element['#ajax'] = [
      'callback' => [
        get_class($this),
        'buildAjaxEntitiesSelectTable',
      ],
      'effect' => 'fade',
      'method' => 'replace',
      'wrapper' => 'entities-wrapper',
    ];
    $form['channel_wrapper']['channel'] = $select_element;
  }

  // Container for the AJAX.
  $form['channel_wrapper']['entities_wrapper'] = [
    '#type' => 'container',
    // Force an id because otherwise default id is changed when using AJAX.
    '#attributes' => [
      'id' => 'entities-wrapper',
    ],
  ];
  $this
    ->buildEntitiesSelectTable($form, $form_state);
}