From 1c8ce46697cfa838550378d52f2528c97a44a4b3 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Sat, 21 May 2022 00:57:02 -0700 Subject: [PATCH] Fix minor bugs in forms not showing errors and whatnot --- assets/css/app.css | 3 +-- lib/aggiedit/rooms/post.ex | 2 +- lib/aggiedit_web/templates/layout/root.html.heex | 7 ++++--- lib/aggiedit_web/views/error_helpers.ex | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/css/app.css b/assets/css/app.css index 0bab67f..0d7e35a 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -27,10 +27,9 @@ .alert:empty { display: none; } -.invalid-feedback { +.error-feedback { color: #a94442; display: block; - margin: -1rem 0 2rem; } /* LiveView specific classes for your customization */ diff --git a/lib/aggiedit/rooms/post.ex b/lib/aggiedit/rooms/post.ex index e1aa59a..8a14829 100644 --- a/lib/aggiedit/rooms/post.ex +++ b/lib/aggiedit/rooms/post.ex @@ -21,7 +21,7 @@ defmodule Aggiedit.Rooms.Post do def changeset(post, attrs) do post |> cast(attrs, [:title, :body, :score]) - |> validate_required([:title, :body]) + |> validate_required([:title]) end def change_user(post, user) do diff --git a/lib/aggiedit_web/templates/layout/root.html.heex b/lib/aggiedit_web/templates/layout/root.html.heex index 861ed8b..d8ce08e 100644 --- a/lib/aggiedit_web/templates/layout/root.html.heex +++ b/lib/aggiedit_web/templates/layout/root.html.heex @@ -6,13 +6,14 @@ <%= csrf_meta_tag() %> <%= live_title_tag assigns[:page_title] || "Aggiedit" %> - - - + + + +
diff --git a/lib/aggiedit_web/views/error_helpers.ex b/lib/aggiedit_web/views/error_helpers.ex index 651e48f..f2cf2b5 100644 --- a/lib/aggiedit_web/views/error_helpers.ex +++ b/lib/aggiedit_web/views/error_helpers.ex @@ -11,7 +11,7 @@ defmodule AggieditWeb.ErrorHelpers do def error_tag(form, field) do Enum.map(Keyword.get_values(form.errors, field), fn error -> content_tag(:span, translate_error(error), - class: "invalid-feedback", + class: "error-feedback", # changed from invalid-feedback because bootstrap 5 has invalid-feedback already defined phx_feedback_for: input_name(form, field) ) end)