protected function ViewsBulkOperationsFormTrait::getFormData in Views Bulk Operations (VBO) 8.2
Same name and namespace in other branches
- 8.3 src/Form/ViewsBulkOperationsFormTrait.php \Drupal\views_bulk_operations\Form\ViewsBulkOperationsFormTrait::getFormData()
- 8 src/Form/ViewsBulkOperationsFormTrait.php \Drupal\views_bulk_operations\Form\ViewsBulkOperationsFormTrait::getFormData()
- 4.0.x src/Form/ViewsBulkOperationsFormTrait.php \Drupal\views_bulk_operations\Form\ViewsBulkOperationsFormTrait::getFormData()
Helper function to prepare data needed for proper form display.
Parameters
string $view_id: The current view ID.
string $display_id: The current view display ID.
Return value
array Array containing data for the form builder.
2 calls to ViewsBulkOperationsFormTrait::getFormData()
- ConfigureAction::buildForm in src/
Form/ ConfigureAction.php - Form constructor.
- ConfirmAction::buildForm in src/
Form/ ConfirmAction.php - Form constructor.
File
- src/
Form/ ViewsBulkOperationsFormTrait.php, line 38
Class
- ViewsBulkOperationsFormTrait
- Defines common methods for Views Bulk Operations forms.
Namespace
Drupal\views_bulk_operations\FormCode
protected function getFormData($view_id, $display_id) {
// Get tempstore data.
$form_data = $this
->getTempstoreData($view_id, $display_id);
// Get data needed for selected entities list.
if (!empty($form_data['list'])) {
$form_data['entity_labels'] = [];
$form_data['selected_count'] = 0;
foreach ($form_data['list'] as $item) {
$form_data['selected_count']++;
$form_data['entity_labels'][] = $item[4];
}
}
elseif ($form_data['total_results']) {
$form_data['selected_count'] = $form_data['total_results'];
}
else {
$form_data['selected_count'] = (string) $this
->t('all');
}
return $form_data;
}