When showing a form for some resource’s update action, how can I show the existing data on render.
form =
id
|> AdvisorKey.get_by_id!(load: :users_join_assoc)
|> AshPhoenix.Form.for_update(:update,
as: "advisor_key",
api: NaviClient.Clients,
forms: [auto?: true]
)
|> to_form()
update :update do
accept [:name]
argument :users_join_assoc, {:array, :map} do
allow_nil? true
end
change manage_relationship(:users_join_assoc,
on_no_match: :create,
on_match: :ignore,
on_missing: :destroy
)
end
relationships do
many_to_many :users, NaviClient.Accounts.User do
through NaviClient.Clients.AdvisorKeyUser
source_attribute_on_join_resource :advisor_key_id
destination_attribute_on_join_resource :user_id
end
end
This is how I create the form, when I access the form value like form[:users_join_assoc].value
the expected non empty list of values is present. However when I render the form with inputs_for/1
, no content is rendered. Manually setting the nested form and setting the data option had no effect either. This test seems to do what I want, but I can’t replicate the behaviour.