There are basically two ways to do this in Drupal 8:
- using
hook_form_views_bulk_operations_confirm_action_alter
. This will allow you to alter the list, for example with custom values and code.
- If you have defined a custom action plugin, then in the plugin annotiation you can declare the route name to a custom validation form. This will allow you to do anything you want, including multi-step forms. When you define that custom form, you should subclass Drupal\views_bulk_operations\Form\ConfirmAction, since it's buildForm method takes parameters additional to that of a regular form. So your Plugin would start like this:
/**
* Action description.
*
* @Action(
* id = "my_special_action",
* label = @Translation("My Special Action"),
* type = "custom_entity",
* confirm_form_route_name = "my_module.my_special_action_confirm_form",
* )
*/
class MySpecialAction extends ViewsBulkOperationsActionBase {
}
and the Form will look something like this:
use Drupal\views_bulk_operations\Form\ConfirmAction;
class MySpecialActionConfirmForm extends ConfirmAction {
public function getFormId() {
return 'my_special_action_confirm_form';
}
public function buildForm(array $form, FormStateInterface $form_state, $view_id = NULL, $display_id = NULL) {
....
}
In the custom form class, you will have to define your own submitForm method, if you want to pass anything special to the custom action.