public function SocialEventManagersViewsBulkOperationsBulkForm::viewsForm in Open Social 8.6
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::viewsForm()
- 8.5 modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::viewsForm()
- 8.7 modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::viewsForm()
- 8.8 modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::viewsForm()
- 10.3.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::viewsForm()
- 10.0.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::viewsForm()
- 10.1.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::viewsForm()
- 10.2.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::viewsForm()
File
- modules/
social_features/ social_event/ modules/ social_event_managers/ src/ Plugin/ views/ field/ SocialEventManagersViewsBulkOperationsBulkForm.php, line 124
Class
- SocialEventManagersViewsBulkOperationsBulkForm
- Defines the Enrollments Views Bulk Operations field plugin.
Namespace
Drupal\social_event_managers\Plugin\views\fieldCode
public function viewsForm(array &$form, FormStateInterface $form_state) {
$this->view
->setExposedInput([
'status' => TRUE,
]);
parent::viewsForm($form, $form_state);
if ($this->view
->id() !== 'event_manage_enrollments') {
return;
}
$action_options = $this
->getBulkOptions();
if (!empty($this->view->result) && !empty($action_options)) {
$list =& $form[$this->options['id']];
foreach ($this->view->result as $row_index => $row) {
$entity = $this
->getEntity($row);
$list[$row_index]['#title'] = $this
->getEntityLabel($entity);
}
}
// Get pager data if available.
if (!empty($this->view->pager) && method_exists($this->view->pager, 'hasMoreRecords')) {
$pagerData = [
'current' => $this->view->pager
->getCurrentPage(),
'more' => $this->view->pager
->hasMoreRecords(),
];
}
$display_select_all = isset($pagerData) && ($pagerData['more'] || $pagerData['current'] > 0);
// Select all results checkbox.
if ($display_select_all) {
$form['header'][$this->options['id']]['select_all'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Select all @count results in this view', [
'@count' => $this->tempStoreData['total_results'] ? ' ' . $this->tempStoreData['total_results'] : '',
]),
'#attributes' => [
'class' => [
'vbo-select-all',
'form-no-label',
'checkbox',
],
],
];
}
$wrapper =& $form['header'][$this->options['id']];
$wrapper['#attributes']['class'][] = 'card';
$wrapper['#attributes']['class'][] = 'card__block';
$form['#attached']['library'][] = 'social_event_managers/views_bulk_operations.frontUi';
// Render page title.
$count = isset($this->tempStoreData['list']) ? count($this->tempStoreData['list']) : 0;
$title = $this
->formatPlural($count, '<b>@count enrollee</b> is selected', '<b>@count enrollees</b> are selected');
$wrapper['multipage']['#title'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'class' => [
'placeholder',
],
],
'#value' => $title,
];
$wrapper['multipage']['list']['#title'] = $this
->t('See selected enrollees on other pages');
// We don't show the multipage list if there are no items selected.
$items = isset($wrapper['multipage']['list']['#items']) ? count($wrapper['multipage']['list']['#items']) : 0;
if ($items < 1) {
unset($wrapper['multipage']['list']);
}
$actions =& $wrapper['actions'];
$actions['#theme'] = 'links__dropbutton__operations__actions';
$actions['#label'] = $this
->t('Actions');
unset($actions['#type']);
unset($wrapper['multipage']['clear']);
$labels = [];
foreach (Element::children($actions) as $action_id) {
$labels[$action_id] = $actions[$action_id]['#value'];
}
asort($labels);
foreach (array_keys($labels) as $weight => $action_id) {
$actions[$action_id]['#weight'] = $weight;
}
$items = [];
foreach (Element::children($actions, TRUE) as $key) {
$items[$key] = $actions[$key];
}
$actions['#links'] = $items;
$form['actions']['#access'] = FALSE;
}