I noticed the following hidden input is being added by inputs_for
<input type="hidden" name="draft_order_creation_form[items][0][_persistent_id]" value="0">
But this is the changeset i’m turning into a form with to_form
, why wouldn’t there be an id in the params ?
the form: %Phoenix.HTML.Form{
source: #Ecto.Changeset<
action: :validate,
changes: %{
items: [
#Ecto.Changeset<
action: :insert,
changes: %{
id: "01J3TDKVKQNFGMMM44FP0N8074",
name: "400g / Einzeldose",
image: "a",
quantity: 1,
price: Decimal.new("2.99"),
variant_id: "01J3TDKVKQNFGMMM44FP0N8074"
},
errors: [],
data: #Pdex.DraftOrderCreationForm.Item<>,
valid?: true
>
],
shipping: #Ecto.Changeset<
action: :insert,
changes: %{method: "dpd"},
errors: [price: {"can't be blank", [validation: :required]}],
data: #Pdex.DraftOrders.Shipping<>,
valid?: false
>,
discount: #Ecto.Changeset<
action: :insert,
changes: %{unit: :money},
errors: [value: {"can't be blank", [validation: :required]}],
data: #Pdex.DraftOrders.Discount<>,
valid?: false
>
},
errors: [
customer_id: {"can't be blank", [validation: :required]},
shipping_address_id: {"can't be blank", [validation: :required]},
billing_address_id: {"can't be blank", [validation: :required]}
],
data: #Pdex.DraftOrderCreationForm<>,
valid?: false
>,
impl: Phoenix.HTML.FormData.Ecto.Changeset,
id: "draft_order_creation_form",
name: "draft_order_creation_form",
data: %Pdex.DraftOrderCreationForm{
order_id: nil,
customer_id: nil,
shipping_address_id: nil,
billing_address_id: nil,
note: nil,
market_id: "01J3TCZA758GVB40QD7RWD6DTB",
tags: [],
discount: nil,
shipping: nil,
items: []
},
action: nil,
hidden: [],
params: %{
"customer_id" => "",
"customer_id_text_input" => "",
"discount" => %{
"_persistent_id" => "0",
"reason" => "",
"unit" => "money",
"value" => ""
},
"items" => [
%{
"id" => "01J3TDKVKQNFGMMM44FP0N8074",
"image" => "a",
"name" => "400g / Einzeldose",
"price" => "2.99",
"product_name" => nil,
"quantity" => 1,
"variant_id" => "01J3TDKVKQNFGMMM44FP0N8074"
}
],
"items_text_input" => "",
"market_id" => "01J3TCZA758GVB40QD7RWD6DTB",
"note" => "",
"shipping" => %{"_persistent_id" => "0", "method" => "dpd", "price" => ""},
"tags_empty_selection" => "",
"tags_text_input" => ""
},
errors: [
customer_id: {"can't be blank", [validation: :required]},
shipping_address_id: {"can't be blank", [validation: :required]},
billing_address_id: {"can't be blank", [validation: :required]}
],
options: [method: "post"],
index: nil
}