Action afterStateHydrated

Hello, i want to fire a Action after a user has chosen something in the dropdown of my form, how can i achieve this?
5 Replies
sandofgods
sandofgods3mo ago
Just do you logic in the ->afterStateUpdated
torpedo
torpedo3mo ago
yeah, but the logic is the action.. i like to open the action itself with the form etc.. so not sure how to trigger that
sandofgods
sandofgods3mo ago
so you want to open a new form depending on the select in your form that right? i think we need little more context to help us to find a solution. for what i know, you can't open an action from a select unless you manually create a custom input with all your stuff (modal, form ...) and use the live() option and inject JS to handle the opening and all the form functionnalities. so with little more context, we maybe can find another way.
torpedo
torpedo3mo ago
my case: after the status is chosen by the user to lets say active, i want the user to check/fill relevant fields like start_date and some invoice fields.. in case of deactivated end_date and so on..
sandofgods
sandofgods3mo ago
ok its very simple, use dependant fields, have all of your field in your form, and use ->hidden() and ->live() to show them and hide them depend on the select id. Check those links: https://filamentphp.com/docs/3.x/forms/getting-started#dependant-fields Explanation about Get and Set classes: https://filamentphp.com/docs/3.x/forms/advanced#injecting-the-state-of-another-field