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
This commit is contained in:
parent
e826fabf18
commit
085a506205
2 changed files with 8 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<span data-controller="modal" data-modal-root-selector-value="#add-navigation-link-modal-root" data-modal-content-selector-value="#add-navigation-link-modal" data-modal-title-value="Add Navigation Link" data-modal-size-value="l">
|
||||
<button class="btn btn-primary ml-7" type="button" data-action="modal#toggleModal" id="nav-link-button">
|
||||
<button class="btn btn-primary" type="button" data-action="modal#toggleModal" id="nav-link-button">
|
||||
Add Navigation Link
|
||||
</button>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<div class="form-group">
|
||||
<%= form.label :name %>
|
||||
<%= form.text_field :name, class: "form-control" %>
|
||||
<%= form.text_field :name, class: "form-control", required: true %>
|
||||
<div class="alert alert-info">A friendly name for the navigation link</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= 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 %>
|
||||
<div class="alert alert-info">A full (external) or relative (internal) URL for the link</div>
|
||||
</div>
|
||||
<div class="form-group" data-controller="svg-icon-upload">
|
||||
|
|
@ -17,8 +17,11 @@
|
|||
<%= form.hidden_field :icon, "data-svg-icon-upload-target": "svgIconContent" %>
|
||||
|
||||
<input
|
||||
type="file" accept="image/svg+xml" class="form-control-file"
|
||||
data-action="svg-icon-upload#selectSvgIcon" />
|
||||
type="file"
|
||||
accept="image/svg+xml"
|
||||
class="form-control-file"
|
||||
data-action="svg-icon-upload#selectSvgIcon"
|
||||
<%= form.object[:icon].blank? ? "required=true" : "" %> />
|
||||
|
||||
<div class="alert alert-info">An SVG icon should be uploaded</div>
|
||||
<div data-svg-icon-upload-target="svgIconMessageValidate"></div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue