Closed rmoorman closed 1 hour ago
Remove the default nil value for the as attribute in the generated simple_form core component.
nil
as
simple_form
This default interferes with the form name present in the form struct provided through the component's for attribute when used with :let=.
for
: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:
f.name
name
bar
<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.
Fixes phoenixframework/phoenix#5901
Thank you! 🙌
Remove the default
nil
value for theas
attribute in the generatedsimple_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:
When rendered,
f.name
isnil
, and thename
attribute of the form field only containsbar
, missing the proper field name prefix from the form struct:This issue been reported over here.
Fixes phoenixframework/phoenix#5901