1 views_handler_field_bulk_form.inc | views_handler_field_bulk_form::views_form_submit(&$form, &$form_state) |
Submit handler for the bulk form.
Parameters
array $form: An associative array containing the structure of the form.
array $form_state: An associative array containing the current state of the form.
File
- core/
modules/ views/ handlers/ views_handler_field_bulk_form.inc, line 148 - Definition of views_handler_field_bulk_form.
Class
- views_handler_field_bulk_form
- Defines a actions-based bulk operation form element.
Code
function views_form_submit(&$form, &$form_state) {
if ($form_state['step'] == 'views_form_views_form') {
$action_name = $form_state['values']['action'];
$action_info = actions_get_info($form_state['values']['action']);
$count = 0;
// Filter only selected checkboxes.
$selected = array_filter($form_state['values'][$this->options['id']]);
if (!empty($selected)) {
$entity_type = $this->get_entity_type();
$entities = entity_load($entity_type, $selected);
$context = array();
foreach ($entities as $entity) {
if (actions_execute($action_name, $entity, $context) !== FALSE) {
$count++;
}
}
// Redirect the user the same as we would for $form_state['redirect'].
if (isset($context['redirect'])) {
actions_redirect($context['redirect']);
}
}
else {
backdrop_set_message(t('No items selected.'), 'error');
}
if ($count) {
backdrop_set_message(format_plural($count, '%action was applied to @count item.', '%action was applied to @count items.', array('%action' => $action_info['label'])));
}
}
}