modalHidden() something is wrong?

Hi, A customer of mine has hundreds of fields on the same record/model/resource. Only ten of them are required. He receives the records partially filled from a web form. So fields are not really required, only logically required. The fact is that they would like to be able to save the record, even with empty "required" fields and only check if some are missing when calling some action with the record. I know how to "fake" the requireness of the fields with some extraAttributes class and some css. That is not a problem. The problem is that I need the Action to test if something is missing BEFORE actually acting, and showing a modal with info of what is missing... or simply act if nothing is missing. I thought the modalHidden() function was my friend on that, but I might not understand how it works, because it don't do what I mean to: Action::make('doSomethig') ->modalHidden( fn (Component $livewire):bool => $livewire->noRequiredFieldsMissing()) ->modalContent(view('filament.view.showrequiredfieldsmissing')) ->action('doSomething') As I understand from info, modal should only appear if modalHidden is false, and if it is not it should fall back to action. But if I add an action() to the Action description it always calls to the action, regardless of what modalHidden is saying. Could anybody give me a clue on what to look for? I am out of clues. Maybe there is another way to check if some condition is or is not meet before actually executing the action? Is there a way to create a modal from within a component action function? I could test if all required data is filled before executing the action, but someway I should be able to send a Modal to the browser if something is missing. A notification is not big enough in this case.
Solution:
But if you use ->action(function (?Model $record, array $data): void { $this->dades=$data; $this->doSomething(); } ) Then everything works as expected....
Jump to solution
2 Replies
epertinez
epertinezOP13mo ago
ok. I reply to myself: when actions are set as an string that represents the name of the function, for whatever reason, they are always executed.
Solution
epertinez
epertinez13mo ago
But if you use ->action(function (?Model $record, array $data): void { $this->dades=$data; $this->doSomething(); } ) Then everything works as expected.
Want results from more Discord servers?
Add your server