I’m trying to implement create/update actions where I manually create the changeset for the embed. This is what I currently tried, but the creation fails with an error, because the translations are missing (Ash.Error.Changes.Required
)
attributes do
attribute :translations, __MODULE__.Translations, private?: true, allow_nil?: false
end
create :create do
primary? true
change &cast_translations/2
end
defp cast_translations(changeset, context) do
translations_changeset =
Ash.Changeset.new(
changeset.data.translations || __MODULE__.Translations,
changeset.params
)
Ash.Changeset.set_argument(changeset, :translations, translations_changeset)
end