Inputs_for as: seems to be omitted from response

Hey there,

I have this code:

<%= for field <- [:free_event_rsvp] do %>
                        <div class="row">
                            <div class="col-2">
                                <p><%= String.capitalize(Atom.to_string(field)) %></p>
                            <div class="col-10"  >
                              <%= inputs_for f, :business_webhooks, [as: :webhooks], fn fp -> %>
                                <%= text_input fp, :free_event_rsvp %>
                              <% end %>
                                <p class="text-danger"><%= error_tag f, field %></p>
                        <div class="hr-line-dashed"></div>
                    <% end %>

but if i have the

> as: :webhooks

added the filed is not included upon submit.
Without it the field is there, but i need it with a different name.

What’s the input :free_event_rsvp generated name attribute in the 1st case vs the 2nd case?

hey, thanks for the response!

without as:


with as:


if i do this in as:

[as: "business_account[webhooks]"]

then the name is as it should be, but is this the proper way?

That’s it. Seems that :as doesn’t care if it’s part of an inputs_for. I would have expected it to not overwrite the whole attribute, but only its part, but then again if you would have wanted to keep that part outside of the main form_data for whatever reasons, you wouldn’t be able to. So, I suppose, the current implementation is more flexible.

1 Like