Do not run BulkAction for any records if some do not pass policy validation
Hey Filament Discord! First of all, huge thanks for all maintainers of this package.
I have a question regarding bulk actions. I saw that it is possible to individually authorize them for each record, which is cool:
In this case,
executeAction
will only receive the records which pass doStuff
, and will only execute my action for those.
However, in such cases where some records get thrown out, I would like if the action did not execute for any records, not even for those that passed the policy.
I saw that I can inject the $records
and $action
in my action()
callback, and can look for differences if needed:
But it'd be a bit troublesome to insert this logic into all of my bulk actions.
So my question is, is there a more elegant, Filament way I can do this?
Refusing to run the action when some records do not pass a policy?
Or would I need to extend BulkAction
and add some custom logic?
If so, could I get some tips on how I can cleanly do it?
My reason for wanting to do this is that I think it's simpler to understand for the end user.
"Your selection mixed in some incorrect records, so nothing will be done, please try again." is the way I want to go by.
Thank you for your help in advance.0 Replies