Field does not save when used from inline form
Opened this issue · 7 comments
In Nova4 Inline HasOne Creation has been introduced that allows to create/update a HasOne
/MorphOne
relation from the parent resource.
However it seems MorphOne
it is not compatible with Nova-Translatable.
I can see the field and the language selectors but when I update the model, the values do not get stored.
bug.mov
There are no errors on laravel.log
or browser console.
Also, validation does work but with no visual indicator on the field or error message.
If I edit the relation outside the parent resource, everything works as expected.
Same problem here can't figure out what's wrong
This is not a fix but a turnaround
MorphOne::make('Seo')
->hideWhenUpdating()
->hideWhenCreating(),
The fields don't save when created inline, still we'll be able to develop until a solution is found
Tried debugging this issue, but no cigar unfortunately.
I think the problems lies in the Vue component.
When editing the Model from it's own resource (not trough the relation) you can see the request having the language attributes within the field.
When doing the same update, but now trough the parent model and by using the Morph relationship you can see the attributes are missing from the request.
Hopefully these steps help a bit in reproducing the issue. I'll give debugging the Vue components a shot. Will update here on any findings.
Did some more debugging and found a difference when the fill()
method is called from a regular Model vs a relation
When console logging the formData
on line 96
nova-translatable/resources/js/components/FormField.vue
Lines 71 to 106 in 0dd45b7
When called from a regular model:
When called from trough the Morph relationship:
It seems to me that that somehow within the fill()
method there's a need to apply some sort of logic on determining if the update is coming trough a relation.
Hey @miagg!
Could you share more details so we could reproduce your issue?
Currently tested it on nova 4.22.2 and the new hasOne
relation was created with the translation.
Hi @eugenl1nde,
Sorry, I forgot to mention that the relation field is a MorphOne
field instead of HasOne
.
I tried again with Nova 4.22.2
just to be sure and it does not work. See video for more details.
Also, I tried #94 and it seems to do the job.
Any progress on this?
I noticed that validation does not kick either, so I had to revert to hiding the MorphOne field until it is officially supported by the package.