Repository navigation
Conversation
A brick configures its form's action in configureBrickAction(), but a field had no way to change it for its own context, e.g. a slide-over or a width, without touching every brick. brickAction() takes a callback that runs after the brick's configuration, like Filament's Repeater::addAction(). It receives the action, the brick's class and the action's arguments; returning null keeps the action. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
awcodes
left a comment
There was a problem hiding this comment.
Thanks. This is the kind of small, general hook I had in mind, and it runs in the right place, after the brick's own configureBrickAction().
One problem: Filament ignores the return value of bootUsing (CanBeBooted::boot()). So unlike Repeater::addAction(), a callback that returns a different Action instance does nothing. Only changing the action it was given takes effect. The docs and the description say "the callback receives the action and returns it", which leads people to the version that breaks.
Could you either:
- change the docs to say the callback should modify the
$actionit receives, and return it ornull; or - make a returned new instance actually take effect, if there's a clean way to do that within
bootUsing?
Also, if #91 lands, a callback that sets afterFormFilled() would turn off the part lookup. I'll keep that in mind wherever those two meet.
…ferent one Filament ignores what bootUsing() returns, so a callback that returned a new action did nothing. The docs now say the callback changes the $action it receives and may return it or null, and returning a different action throws a LogicException instead of being silently dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Went with the first option in bbd3d81. A new instance can't take effect cleanly: by the time bootUsing() runs, the action is already mounted, and copying a returned action's settings onto it would mean mirroring Filament's internals. So the docs now say the callback changes the $action it receives and may return it or null, and returning a different action throws a LogicException instead of being silently dropped. There's a test for that. Noted on #91 and afterFormFilled(); I'll follow up on whichever of the two lands second. |
One of the small, general hooks you offered in #73. A brick configures its form's action in
configureBrickAction(), but a field had no way to adjust it for its own context without touching every brick or copyingBrickAction's internals.The callback changes the $action it receives and may return it or null. It runs in BrickAction's bootUsing() right after the brick's configureBrickAction(), so the field gets the last word, since it knows the context. Filament ignores what bootUsing() returns, so a callback cannot swap in a new action; returning a different instance throws a LogicException rather than doing nothing. It also receives the brick's class as $brick and the action's $arguments (with mode being insert or edit), so it can differ per brick or per mode.
Our use case: a Mason field inside a brick's own form, whose brick forms should open beside the outer slide-over instead of over it (
overlayParentActions()plus a class withmerge: true). Today that needs a copy of thebootUsing()logic, which silently drifts wheneverBrickAction::make()changes. Other uses: a slide-over or width per field, labels, orauthorize().Tests go through the Livewire action on insert and edit: the brick's configuration without a callback, the callback overriding it, a
nullreturn, the parameters passed, and saving with a customized action. Docs: "Brick form" indocs/fields/customizing.md.🤖 Generated with Claude Code