public function ViewsBulkOperationsBulkForm::viewsFormValidate in Views Bulk Operations (VBO) 8
Same name and namespace in other branches
- 8.3 src/Plugin/views/field/ViewsBulkOperationsBulkForm.php \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm::viewsFormValidate()
- 8.2 src/Plugin/views/field/ViewsBulkOperationsBulkForm.php \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm::viewsFormValidate()
- 4.0.x src/Plugin/views/field/ViewsBulkOperationsBulkForm.php \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm::viewsFormValidate()
File
- src/
Plugin/ views/ field/ ViewsBulkOperationsBulkForm.php, line 699
Class
- ViewsBulkOperationsBulkForm
- Defines the Views Bulk Operations field plugin.
Namespace
Drupal\views_bulk_operations\Plugin\views\fieldCode
public function viewsFormValidate(&$form, FormStateInterface $form_state) {
if ($this->options['buttons']) {
$trigger = $form_state
->getTriggeringElement();
$action_id = end($trigger['#parents']);
$form_state
->setValue('action', $action_id);
}
if (empty($form_state
->getValue('action'))) {
$form_state
->setErrorByName('action', $this
->t('Please select an action to perform.'));
}
// This happened once, can't reproduce but here's a safety switch.
if (!isset($this->actions[$form_state
->getValue('action')])) {
$form_state
->setErrorByName('action', $this
->t('Form error occurred, please try again.'));
}
if (!$form_state
->getValue('select_all')) {
$selected = array_filter($form_state
->getValue($this->options['id']));
if (empty($selected)) {
$form_state
->setErrorByName('', $this
->t('No items selected.'));
}
}
// Action config validation (if implemented).
if (empty($this->options['form_step']) && !empty($form['header'][$this->options['id']]['configuration']['#config_included'])) {
$action_id = $form_state
->getValue('action');
$action = $this->actions[$action_id];
if (method_exists($action['class'], 'validateConfigurationForm')) {
$actionObject = $this->actionManager
->createInstance($action_id);
$actionObject
->validateConfigurationForm($form['header'][$this->options['id']]['configuration'], $form_state);
}
}
}