protected function PullForm::buildChannelSelect in Entity Share 8
Same name and namespace in other branches
- 8.3 modules/entity_share_client/src/Form/PullForm.php \Drupal\entity_share_client\Form\PullForm::buildChannelSelect()
- 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 324
Class
- PullForm
- Form controller to pull entities.
Namespace
Drupal\entity_share_client\FormCode
protected function buildChannelSelect(array &$form, FormStateInterface $form_state) {
$selected_remote = $form_state
->getValue('remote');
// No remote selected.
if (empty($selected_remote)) {
$triggering_element = $form_state
->getTriggeringElement();
$get_remote = $this->query
->get('remote');
// If it is not an ajax trigger, check if it is in the GET parameters.
if (!is_array($triggering_element) && !is_null($get_remote) && isset($this->remoteWebsites[$get_remote])) {
$selected_remote = $get_remote;
}
else {
return;
}
}
$selected_remote = $this->remoteWebsites[$selected_remote];
$this->channelsInfos = $this->remoteManager
->getChannelsInfos($selected_remote);
$form['channel_wrapper']['channel'] = [
'#type' => 'select',
'#title' => $this
->t('Channel'),
'#options' => $this
->getChannelOptions(),
'#default_value' => $this->query
->get('channel'),
'#empty_value' => '',
'#required' => TRUE,
'#ajax' => [
'callback' => [
get_class($this),
'buildAjaxEntitiesSelectTable',
],
'wrapper' => 'entities-wrapper',
'method' => 'replace',
'effect' => 'fade',
],
];
// 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);
}