How to get the form data in a RelationManager create or edit action?

Currently i have a form with three fields, in the edit action in the before() hook im trying to access the current form data but it's not bringing the Select Input field that is a multiple relationship (belongsToMany), any ideias why?
No description
No description
No description
2 Replies
Dennis Koch
Dennis Koch5w ago
Fields using ->relationship() are saved directly, and therefore the data is not included. I think ->dehydrated(false) is the right way to stop this and get the data Another way could be this:
->before(fn ($livewire) => $livewire->mountedActionsData['mentions']
->before(fn ($livewire) => $livewire->mountedActionsData['mentions']
Firebat
FirebatOP4w ago
So i was testing, this one doesn't return the field on $data on mutateformdata or before tried this one too but it says the key it's not defined well, i found a way create a variable, in the relationship field that you want to work with the data add ->live and ->afterStateUpdated and in the afterStateUpdated save the state on the variable you created so you can access it in the action

Did you find this page helpful?