Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty errors with two level nested form using version 4.5.0 #173

Closed
alejandrodevs opened this issue Mar 4, 2024 · 7 comments
Closed

Empty errors with two level nested form using version 4.5.0 #173

alejandrodevs opened this issue Mar 4, 2024 · 7 comments

Comments

@alejandrodevs
Copy link

alejandrodevs commented Mar 4, 2024

I was using version 4.4.3 version and everything was working fine. After I migrated to version 4.5.0 the errors in the deepest nested form weren't shown.

Example:

<.form for={@form} phx-submit={@action}>
    … Errors shown correctly after submit.

    <.inputs_for :let={nested_1} field={@form[:nested_1]}>
        … Errors shown correctly after submit.

        <.inputs_for :let={nested_2} field={nested_1[:nested_2]}>
            … Errors are empty and not showing correctly after submit.
        </.inputs_for>
    </.inputs_for>
</.form>

After checking the latest changes I found this:
a9e1a3d#diff-097986c2a86bfdab8c54b295763f1a6d47b1e86bf91bb9618715fc82b5661269R65

If I am not missing something, this only works with just one level nested form because the parent form action is present. Two-level nested form will not shown the errors because the parent form is the one-level nested form which has action nil.

Any thoughts on this? Should this be setting the action in child nested forms to avoid this?
Please let me know if I am missing something.

@ibarchenkov
Copy link

I've stumbled upon the same issue. As you suggested, passing parent_action to the nested forms seem to help, but I'm unaware of the possible implications of adding this line:

action: changeset.action,

here and there.

@nthock
Copy link

nthock commented Mar 7, 2024

+1 on facing the same issue in this upgrade

@josevalim
Copy link
Member

Can you please try main and let me know? If it works I will ship a new release asap. :)

@johantell
Copy link

I can verify that the commit solved the problem for us :)

@nthock
Copy link

nthock commented Mar 7, 2024

Also confirmed that this commit solved the problem.

@ibarchenkov
Copy link

Works for me as well. Thanks Jose! ❤️

@josevalim
Copy link
Member

4.5.1 is out, enjoy! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants