Display Changeset Errors
Learn how to display changeset errors.
We'll cover the following
Our form is working well, but something is missing. If the user submits invalid data, the call to Repo.insert
will fail. We currently have no way of showing the user how to fix the problem, though. The changeset contains the validation errors, so we need to add some elements to the page to display them. Let’s do that now.
Add helper functions
We’ll start by adding a new helper function, error_tag/2
. This function is not provided by default, so we need to define it ourselves. We can add it to any module we’re using for storing helper functions.
Get hands-on with 1400+ tech skills courses.