ca1989
July 27, 2023, 3:11pm
1
Hi all,
I am seeing form errors while a live view is loading. Then they disappear.
I am using a vanilla Phoenix project with tailwind and core components to render the form.
You can see the source code at:
https://github.com/carlotm/form-errors-are-visible
Is this behaviour intended/known, or am I doing something wrong here?
Cheers!
It’s because you’re setting an action:
https://github.com/carlotm/form-errors-are-visible/blob/51c11b641b30658a6d4fd3ef95938026047c2524/lib/epkgs_web/live/projects_admin_live.ex#L21
You don’t want to set an action on a changeset until you are ready to display errors like in a validate or submit callback
To just build the form, you can remove that line
I would move that line to the validate callback
ca1989
July 27, 2023, 3:29pm
3
Thank you, it was indeed the reason!