Commit 19680de
committed
Preserve original name when
Remove the default `nil` value for the `as` attribute in the generated
`simple_form` core component.
This default interferes with the form name present in the form struct
provided through the component's `for` attribute when used with `:let=`.
For example, consider the following code:
```
<.simple_form :let={f} for={@Form}>
<%= inspect(f.name) %>
<.input field={f[:bar]} label="Bar" />
</.simple_form>
```
When rendered, `f.name` is `nil`, and the `name` attribute of the form
field only contains `bar`, missing the proper field name prefix from
the form struct:
```
<div class="mt-10 space-y-8 bg-white">
nil
<div data-phx-id="m9-phx-GAgAfRg6YU4XV6tC">
<label for="bar" class="block text-sm font-semibold leading-6 text-zinc-800" data-phx-id="m10-phx-GAgAfRg6YU4XV6tC">
Bar
</label>
<input type="text" name="bar" id="bar" class="mt-2 block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6 border-zinc-300 focus:border-zinc-400">
</div>
</div>
```
This issue been reported [over here](#5901).
Fixes #5901as is not provided to simple_form
1 parent dad4527 commit 19680de
File tree
2 files changed
+8
-4
lines changed- installer/templates/phx_web/components
- priv/templates/phx.gen.live
2 files changed
+8
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
133 | 135 | | |
134 | | - | |
| 136 | + | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
133 | 135 | | |
134 | | - | |
| 136 | + | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| |||
0 commit comments