CreateUsingOption() not getting relation in $data
Hello everyone, I am stuck here. I have in a TableRepeater in which I have a Select with a createOptionForm and a createOptionUsing. So it kind of works... I mean, createOptionForm creates the form, I can fill it up normally and when I save it creates the new record. Good BUT, in this record I want to save, I have a relationship (in a Section) and this relation is not saved at all. Neither I get the relation in $data that I pass to createOptionUsing($data).
So in this code if I in createOptionUsing I get something like this :
array:4 [
"name" => "aaaaaaa"
"color" => "#a15353"
"description" => null
"context" => "family"
]
But this is only the half of my form, I was expecting something like
array:4 [
"name" => "aaaaaaa"
"color" => "#a15353"
"description" => null
"context" => "family"
"reverse" => [
"name" => "blablabla"
...
]
]
Does someone can see any reason why I get half of my $data ?
Solution:Jump to solution
I think you can use
->dehydrated()
to get the values instead of saving them directly.7 Replies
Maybe share your form. I guess you are using a relationship field and they are saved directly.
Sorry I don't know if it's too long for a snippet or not. But here is my form.
It's the
relationship('reverse')
partSolution
I think you can use
->dehydrated()
to get the values instead of saving them directly.Oh I will try this, thank you, I'll get back to you !
YES ! It worked ! Thank you ! So relationship automatically findOrCreate and link our records but deactivates the dehydrated ?
Yes, because the values are usually not needed.
Alright ! Thank you so much Dennis !