Form state for fields with relationship
How can I get the submitted data for fields which have a
relationship
defined? When using $data = $this->form->getState();
in forms submit
I only get the data of fields without relationships. I need the whole form data (in a frontend form) to "park" it in session and use it again after user has either logged in or registered.29 Replies
after getState() is called, the relations are saved to the $record
so you can access the data with $record->relationshipName
also without saving the model/record at this point?
why use relationship() at all if you dont want us to do anything with it?
i need the saving process after the user has logged in. the user can make a booking with nested relations and after he/she has logged in or registered i wanted to save the booking
when not using the relationship() i do have to make it all maunally
you could use
->relationship('xxx')->dehydrated()
alright. does this also work for nested relationships?
probably
i think there's still the bug with nested savings
make sure to put it next to all relationship() calls that should be dehydrated
i fixed it though...
already released?
i've just released it in 2.17.22. wait a few mins
https://github.com/filamentphp/filament/pull/6092/files
awesome!
no matter hoe deep the nesting is?
i hope so
i do have 3 levels
i will try it out 🙂
no, still not working
in my case nothing changed with this release
did you open the issue originally?
yes
i used that repo to test the fix
are you sure the changes i made are in /vendor
ah ok - i will have a look when i‘m home again.
my relationship is defined as morphable
i dont remember that in the project you send in the issue?
i will set this up ok?
do you think it would make a difference what type the relation is of?
hey @Dan Harrin i've looked it up and the repo i've provided also had the relationships defined as morphables:
can you point to a specific use case that doesnt work
because i used it to make my original fix
in my screenshot "phone" is always empty - now even the "update" does not work anymore
tried put in the provided repo
here are the models:
GitHub
filament-test/app/Models at main · danielbehrendt/filament-test
Contribute to danielbehrendt/filament-test development by creating an account on GitHub.
and here the resource
GitHub
filament-test/UserResource.php at main · danielbehrendt/filament-test
Contribute to danielbehrendt/filament-test development by creating an account on GitHub.
user -> person (works) -> contact (works not)
i have reopened the issue, this is a complex problem so you will have to be patient with the fix
alright, no problem. i will wait patiently (as it will be an enormous boost and will provide a lot of flexibility) 😉