From 085a506205112ca3451b914b92a250f7468f0699 Mon Sep 17 00:00:00 2001 From: Ridhwana Date: Thu, 21 Oct 2021 12:43:05 +0200 Subject: [PATCH] Navigation Links Validation (#15139) * feat: add a required attribute for the fields on Navigation Links that are required * remove the weird margin * we want the field to be required only when we don't have a vallue from form.object[:icon] that is in the craete view --- .../_add_navigation_link_modal.html.erb | 2 +- app/views/admin/navigation_links/_form.html.erb | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/admin/navigation_links/_add_navigation_link_modal.html.erb b/app/views/admin/navigation_links/_add_navigation_link_modal.html.erb index 8956c877e..5e88eb326 100644 --- a/app/views/admin/navigation_links/_add_navigation_link_modal.html.erb +++ b/app/views/admin/navigation_links/_add_navigation_link_modal.html.erb @@ -1,5 +1,5 @@ - diff --git a/app/views/admin/navigation_links/_form.html.erb b/app/views/admin/navigation_links/_form.html.erb index 3d5c09f03..002258beb 100644 --- a/app/views/admin/navigation_links/_form.html.erb +++ b/app/views/admin/navigation_links/_form.html.erb @@ -1,11 +1,11 @@
<%= form.label :name %> - <%= form.text_field :name, class: "form-control" %> + <%= form.text_field :name, class: "form-control", required: true %>
A friendly name for the navigation link
<%= form.label :url %> - <%= form.text_field :url, class: "form-control" %> + <%= form.text_field :url, class: "form-control", pattern: "^(https?:\/\/|\/)\w+\.[^\s]+$|^\/[^\s]*$", title: "The URL can be absolute by beginning with http/s or it can be relative beginning with a /", required: true %>
A full (external) or relative (internal) URL for the link
@@ -17,8 +17,11 @@ <%= form.hidden_field :icon, "data-svg-icon-upload-target": "svgIconContent" %> + type="file" + accept="image/svg+xml" + class="form-control-file" + data-action="svg-icon-upload#selectSvgIcon" + <%= form.object[:icon].blank? ? "required=true" : "" %> />
An SVG icon should be uploaded