no idea how to use `inputs_for`
Sleepful opened this issue · comments
if I try to add a changeset with nested data like this
%Category{} |> Map.put(:categories_multiselect, [%CategoryMultiselect{name: "def"}]) |> Category.changeset(%{})
then I get an error like this:
lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries or other lists, got invalid entry: %CategoryMultiselect{...}
if I try to add default data like this:
<%= inputs_for f, :categories_multiselect, [default: %CategoryMultiselect{name: "def"}], fn fp -> %>
<%= text_input(fp, :name) %>
<% end %>
i get an error like this:
:default is not supported on inputs_for with changesets. The default value must be set in the changeset data
My %Category schema simply has this: has_many :categories_multiselect, CategoryMultiselect
and I am using the form in the very standard way: <.form let={f} for={@changeset} action={@action}>
and this is not to mention that it seems impossible to use inputs_for
to create a variable amount of inputs
(the user would choose how many) on the client(browser) side for a new resource (changeset would have an empty array because it is a new resource and the number of values to be associated is unknown when the server is generating the HTML template)
Please use the ElixirForum for questions/help/feedback, where a wider community will be able to help you. Otherwise it may take a while for me to be able to dig into this.
@josevalim ok will do