Skip to content

Commit d145eb5

Browse files
authored
Merge pull request #1576 from naymspace/feature/improve-input-label-component
Improve `input_label/1` component
2 parents 576b816 + 7ac81bc commit d145eb5

22 files changed

+42
-27
lines changed

guides/fields/custom-fields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def render_form(assigns) do
3333
<div>
3434
<Layout.field_container>
3535
<:label>
36-
<Layout.input_label text={@field_options[:label]} />
36+
<Layout.input_label for={@form[@name]} text={@field_options[:label]} />
3737
</:label>
3838
<BackpexForm.input
3939
type="text"

guides/fields/readonly.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def render_form(assigns) do
5858
<div>
5959
<Layout.field_container>
6060
<:label>
61-
<Layout.input_label text={@field[:label]} />
61+
<Layout.input_label for={@form[@name]} text={@field[:label]} />
6262
</:label>
6363
<BackpexForm.input
6464
type="text"

guides/upgrading/v0.16.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ end
1414

1515
## Component changes
1616

17-
- `Backpex.HTML.Layout.field_container/1` now uses a `dl` element instead of a `div` element to better align with HTML semantics.
17+
- `Backpex.HTML.Layout.field_container/1` now uses a `dl` element instead of a `div` element to better align with HTML semantics
18+
- `Backpex.HTML.Layout.input_label/1` has been enhanced by adding `as`, `for` and `rest` attribute

lib/backpex/fields/belongs_to.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ defmodule Backpex.Fields.BelongsTo do
136136
<div>
137137
<Layout.field_container>
138138
<:label align={Backpex.Field.align_label(@field_options, assigns)}>
139-
<Layout.input_label text={@field_options[:label]} />
139+
<Layout.input_label for={@form[@owner_key]} text={@field_options[:label]} />
140140
</:label>
141141
<BackpexForm.input
142142
type="select"

lib/backpex/fields/boolean.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ defmodule Backpex.Fields.Boolean do
3737
<div>
3838
<Layout.field_container>
3939
<:label align={Backpex.Field.align_label(@field_options, assigns, :top)}>
40-
<Layout.input_label text={@field_options[:label]} />
40+
<Layout.input_label for={@form[@name]} text={@field_options[:label]} />
4141
</:label>
4242
<BackpexForm.input
4343
type="toggle"

lib/backpex/fields/currency.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ defmodule Backpex.Fields.Currency do
7070
<div>
7171
<Layout.field_container>
7272
<:label align={Backpex.Field.align_label(@field_options, assigns)}>
73-
<Layout.input_label text={@field_options[:label]} />
73+
<Layout.input_label for={@form[@name]} text={@field_options[:label]} />
7474
</:label>
7575
<BackpexForm.input
7676
type="number"

lib/backpex/fields/date.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ defmodule Backpex.Fields.Date do
103103
<div>
104104
<Layout.field_container>
105105
<:label align={Backpex.Field.align_label(@field_options, assigns, :top)}>
106-
<Layout.input_label text={@field_options[:label]} />
106+
<Layout.input_label for={@form[@name]} text={@field_options[:label]} />
107107
</:label>
108108
<BackpexForm.input
109109
type="date"

lib/backpex/fields/date_time.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ defmodule Backpex.Fields.DateTime do
103103
<div>
104104
<Layout.field_container>
105105
<:label align={Backpex.Field.align_label(@field_options, assigns, :top)}>
106-
<Layout.input_label text={@field_options[:label]} />
106+
<Layout.input_label for={@form[@name]} text={@field_options[:label]} />
107107
</:label>
108108
<BackpexForm.input
109109
type="datetime-local"

lib/backpex/fields/email.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ defmodule Backpex.Fields.Email do
4444
<div>
4545
<Layout.field_container>
4646
<:label align={Backpex.Field.align_label(@field_options, assigns, :center)}>
47-
<Layout.input_label text={@field_options[:label]} />
47+
<Layout.input_label for={@form[@name]} text={@field_options[:label]} />
4848
</:label>
4949
<BackpexForm.input
5050
type="email"

lib/backpex/fields/has_many.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ defmodule Backpex.Fields.HasMany do
136136
<div id={@name}>
137137
<Layout.field_container>
138138
<:label align={Backpex.Field.align_label(@field_options, assigns)}>
139-
<Layout.input_label text={@field_options[:label]} />
139+
<Layout.input_label as="span" text={@field_options[:label]} />
140140
</:label>
141141
<div class="dropdown w-full">
142142
<label

0 commit comments

Comments
 (0)