Ash FrameworkAF
Ash Framework3y ago
48 replies
Blibs

AshPhoenix.Form fails in submit without errors with embedded resources

I have a embedded resource like this:

defmodule Marketplace.Markets.Property.OffMarket do
  @moduledoc false

  use Ash.Resource,
    data_layer: :embedded,
    extensions: [AshGraphql.Resource]

  code_interface do
    define_for Marketplace.Markets

    define :new
  end

  attributes do
    alias Marketplace.Ash.Types.PhoneNumber

    attribute :agent_name, :string
    attribute :agent_phone_number, PhoneNumber

    attribute :company_name, :string, allow_nil?: false
    attribute :company_phone_number, PhoneNumber
  end

  graphql do
    type :off_market
  end

  actions do
    defaults [:update, :read, :destroy]

    create :new, primary?: true
  end
end


This embedded resource is used as an attribute inside my Property resource like so: attribute :off_market, OffMarket, allow_nil?: true

I'm having problems when trying to submit an update to it using AshPhoenix.Form.submit, when I run this, it will fail with a {:error, form} reply but there will be no error inside the form.

This is how I initialize the form:

AshPhoenix.Form.for_update(property, :update,
      api: Markets,
      actor: user,
      forms: [auto?: true],
      prepare_source: fn changeset ->
        changeset
        |> Ash.Changeset.set_argument(:uploaded_images, [])
        |> Ash.Changeset.set_argument(:removed_images, [])
      end
    )


After this, I just run the submit function. An I doing something wrong here?
Was this page helpful?