Skip to content

Commit 9c222d6

Browse files
committed
Avoid using label if there is no "for"
1 parent af9dfd9 commit 9c222d6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/petal_components/field.ex

+9-3
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,15 @@ defmodule PetalComponents.Field do
366366

367367
def field_label(assigns) do
368368
~H"""
369-
<label for={@for} class={["pc-label", @class, @required && "pc-label--required"]} {@rest}>
370-
<%= render_slot(@inner_block) %>
371-
</label>
369+
<%= if @for do %>
370+
<label for={@for} class={["pc-label", @class, @required && "pc-label--required"]} {@rest}>
371+
<%= render_slot(@inner_block) %>
372+
</label>
373+
<% else %>
374+
<span class={["pc-label", @class, @required && "pc-label--required"]} {@rest}>
375+
<%= render_slot(@inner_block) %>
376+
</span>
377+
<% end %>
372378
"""
373379
end
374380

0 commit comments

Comments
 (0)