i have Post and Image model. Post has many images. Also have nested form with dinamic images. If validation fails it return changeset without assoc loaded. How i can return user entered data to post and display errors to user?
#Ecto.Changeset<action: :insert,
changes: %{category: "APET",
images: [#Ecto.Changeset<action: :insert,
changes: %{uuid: "a2cf8c14-3cc6-11e8-b152-c85b76d3a09f"},
errors: [url: {"is invalid",
[type: Olist.Images.Uploader.Type, validation: :cast]}],
data: #Olist.Images.Image<>, valid?: false>], user_id: 1},
errors: [heading: {"can't be blank", [validation: :required]},
body: {"can't be blank", [validation: :required]},
price: {"can't be blank", [validation: :required]},
zipcode: {"can't be blank", [validation: :required]}],
data: #Olist.Postings.Posting<>, valid?: false>
pry(2)> changeset.data
%Olist.Postings.Posting{__meta__: #Ecto.Schema.Metadata<:built, "postings">,
address_1: nil, address_2: nil, body: nil, category: nil, heading: nil,
id: nil,
images: #Ecto.Association.NotLoaded<association :images is not loaded>,
inserted_at: nil, price: nil, remote_id: nil, send: nil, updated_at: nil,
user_id: nil, zipcode: nil}
pry(3)> changeset.data
on my form i try this
<div class="row">
<div class="col-sm-12" id="image-list">
<%= for image <- @changeset.data.images do
render "image_fields.html", f: f
end %>
</div>
</div>