inputs_for not working when I do manage_relationship in Ash.Changeset.before_action

Hi team, I would like to ask smth about inputs_for, so when I do manage relatioinship this way change manage_relationship(:beds, type: :create) in the action, inputs_for works. But when I put the manage_relationship in before_action, it doesn't work, e.g.:
change fn changeset, %{actor: actor} = _context ->
Ash.Changeset.before_action(changeset, fn changeset ->
beds = Ash.Changeset.get_argument(changeset, :beds)

Ash.Changeset.manage_relationship(changeset, :beds, beds, type: :create)
end
change fn changeset, %{actor: actor} = _context ->
Ash.Changeset.before_action(changeset, fn changeset ->
beds = Ash.Changeset.get_argument(changeset, :beds)

Ash.Changeset.manage_relationship(changeset, :beds, beds, type: :create)
end
It has this error:
** (AshPhoenix.Form.NoFormConfigured) beds at path [] must be configured in the form to be used with `inputs_for`. For example:

There is an argument called `beds` on the action `MealReports.AshDomains.Lodging.RoomType.create`.

Perhaps you are missing a `change manage_relationship` for that argument, or it is not a type that can have forms generated for it?
** (AshPhoenix.Form.NoFormConfigured) beds at path [] must be configured in the form to be used with `inputs_for`. For example:

There is an argument called `beds` on the action `MealReports.AshDomains.Lodging.RoomType.create`.

Perhaps you are missing a `change manage_relationship` for that argument, or it is not a type that can have forms generated for it?
How can I make inputs_for work when I need to do manage_relationship in the change function? Thanks so much.
2 Replies
ZachDaniel
ZachDaniel2w ago
Yep, so it only automatically sets up the form if you do it as an explicit change. You have to configure the forms manually if you want to do it inside of a hook https://hexdocs.pm/ash_phoenix/nested-forms.html#manually-defining-nested-forms
maccachan0009
maccachan0009OP2w ago
Thanks for the reply, I will take a look and try, thanks again.

Did you find this page helpful?