AshPhoenix nested form not populating
Hello! I ran into an issue with generating nested forms.
I've read through the nested forms docs: https://hexdocs.pm/ash_phoenix/nested-forms.html#defining-the-structure but I can't seem to create a nested form for an optional has_one relationship. I have a resource Submission:
and Submitter:
I've defined the domain extension:
I've tried calling the form generator automatically and manually, but I still can't seem to get the nested form to load. It always comes back as not loaded in the form
source.data
, and no keys under the form
either.
I can work around this by loading the forms separately and validating each.
Any tips on loading the nested submitter form?6 Replies
Thing's I've tried:
Solution
You have to add a form using
AshPhoenix.Form.add_form
The form doesn't assume that you want to fill that field out by default
Ah, is that because it's not a required relationship?
The line from the docs:
AshPhoenix.Form automatically infers what "nested forms" are available, based on introspecting actions which use change manage_relationship. For example, in the following action:
...
made me think it would embed the form automatically. I especially thought it would do so when I manually defined it
Right so it informs the configuration of the forms
I.e what resource and actions they correspond to etc
It doesn't add an empty instance of the forms regardless of the argument being required or not
Oh I see. Thanks for the clarification!