From c918dbe4bf9c1912a55186a9ebaf9293cbc8367b Mon Sep 17 00:00:00 2001 From: shibao Date: Tue, 15 Feb 2022 18:22:58 -0500 Subject: [PATCH] improve changeset errors --- lib/lokal_web/templates/user_registration/new.html.heex | 6 +++--- .../templates/user_reset_password/edit.html.heex | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/lokal_web/templates/user_registration/new.html.heex b/lib/lokal_web/templates/user_registration/new.html.heex index 4718a19..efd16e0 100644 --- a/lib/lokal_web/templates/user_registration/new.html.heex +++ b/lib/lokal_web/templates/user_registration/new.html.heex @@ -5,7 +5,7 @@ <%= form_for @changeset, Routes.user_registration_path(@conn, :create), [class: "flex flex-col justify-center items-center space-y-4"], fn f -> %> - <%= if @changeset.action do %> + <%= if @changeset.action && not(@changeset.valid?) do %>

Oops, something went wrong! Please check the errors below.

@@ -24,7 +24,7 @@ <%= error_tag f, :password %> <%= submit "Register", class: "btn btn-primary" %> - +
@@ -34,4 +34,4 @@ class: "btn btn-primary" %>
<% end %> - \ No newline at end of file + diff --git a/lib/lokal_web/templates/user_reset_password/edit.html.heex b/lib/lokal_web/templates/user_reset_password/edit.html.heex index 1404edd..7d1c570 100644 --- a/lib/lokal_web/templates/user_reset_password/edit.html.heex +++ b/lib/lokal_web/templates/user_reset_password/edit.html.heex @@ -5,7 +5,7 @@ <%= form_for @changeset, Routes.user_reset_password_path(@conn, :update, @token), [class: "flex flex-col justify-center items-center space-y-4"], fn f -> %> - <%= if @changeset.action do %> + <%= if @changeset.action && not(@changeset.valid?) do %>

Oops, something went wrong! Please check the errors below.

@@ -24,9 +24,9 @@ <%= error_tag f, :password_confirmation %> <%= submit "Reset password", class: "btn btn-primary" %> - +
- +
<%= link "Register", to: Routes.user_registration_path(@conn, :new), class: "btn btn-primary" %> @@ -34,4 +34,4 @@ class: "btn btn-primary" %>
<% end %> - \ No newline at end of file +