fixing duplicate input element id issue
This commit is contained in:
parent
e319dda3ad
commit
7e38921e8a
3 changed files with 8 additions and 10 deletions
|
@ -19,14 +19,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= label f, :current_password, class: "form-label" %>
|
<%= label f, :current_password, class: "form-label" %>
|
||||||
<div class="inner-addon left-addon mb-3" phx-feedback-for="<%= input_id(f, :current_password) %>">
|
<div class="inner-addon left-addon mb-3">
|
||||||
<%= icon_div @socket, "bi-lock", [class: "icon is-left text-muted fs-5"] %>
|
<%= icon_div @socket, "bi-lock", [class: "icon is-left text-muted fs-5"] %>
|
||||||
<%= password_input f, :current_password,
|
<%= password_input f, :current_password,
|
||||||
value: input_value(f, :current_password),
|
value: input_value(f, :current_password),
|
||||||
class: "form-control",
|
id: "user_email_current_password",
|
||||||
aria_describedby: error_ids(f, :current_password)
|
class: "form-control"
|
||||||
%>
|
%>
|
||||||
<%= error_tag f, :current_password %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
|
|
@ -30,14 +30,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= label f, :current_password, class: "form-label" %>
|
<%= label f, :current_password, class: "form-label" %>
|
||||||
<div class="inner-addon left-addon mb-3" phx-feedback-for="<%= input_id(f, :current_password) %>">
|
<div class="inner-addon left-addon mb-3">
|
||||||
<%= icon_div @socket, "bi-lock", [class: "icon is-left text-muted fs-5"] %>
|
<%= icon_div @socket, "bi-lock", [class: "icon is-left text-muted fs-5"] %>
|
||||||
<%= password_input f, :current_password,
|
<%= password_input f, :current_password,
|
||||||
value: input_value(f, :current_password),
|
value: input_value(f, :current_password),
|
||||||
class: "form-control",
|
id: "user_password_current_password",
|
||||||
aria_describedby: error_ids(f, :current_password)
|
class: "form-control"
|
||||||
%>
|
%>
|
||||||
<%= error_tag f, :current_password %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
|
|
@ -23,13 +23,13 @@ defmodule Shift73kWeb.ErrorHelpers do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp error_common_opts(form, field, append, opts) do
|
defp error_common_opts(form, field, append, opts) do
|
||||||
Keyword.put(opts, :phx_feedback_for, input_id(form, field))
|
Keyword.put_new(opts, :phx_feedback_for, input_id(form, field))
|
||||||
|> Keyword.update(:class, append, fn c -> "#{append} #{c}" end)
|
|> Keyword.update(:class, append, fn c -> "#{append} #{c}" end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp error_tag_opts({_err, err_index}, opts) do
|
defp error_tag_opts({_err, err_index}, opts) do
|
||||||
input_id = Keyword.get(opts, :phx_feedback_for, "")
|
input_id = Keyword.get(opts, :phx_feedback_for, "")
|
||||||
Keyword.put(opts, :id, error_id(input_id, err_index))
|
Keyword.put_new(opts, :id, error_id(input_id, err_index))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp error_id(input_id, err_index), do: "#{input_id}_feedback-#{err_index}"
|
defp error_id(input_id, err_index), do: "#{input_id}_feedback-#{err_index}"
|
||||||
|
|
Loading…
Reference in a new issue