How to pass on ids for multiple multiple relationships in LiveView with Ash framework

Hello,
I am learning ash with phoenix live view. I am unable to create to create action for a table having multiple relationships. Please go through below.
I have a demand resource where table has slots_id, user_id and booking_volume.

attributes do
    uuid_primary_key :id

    attribute :booked_volume, :integer do
      allow_nil? false
    end
  end

  relationships do
    belongs_to :user,User do
      allow_nil? false
    end

    belongs_to :slots,Slots do
      allow_nil? false
    end
  end

For create action( default i am only accepting :booked_volume for the input field.). For user ID, i am providing @current_user as a actor. So for slot_id. I tried 2 things:

  1. Add one more relate_actor in the change action like, i also made sure i pass :
actions do
    default_accept [:booked_volume]

    changes do
      change relate_actor(:user)
      change relate_actor(:slots)
    end

and i passed as 2 actors in the create for like, i also made sure that slot contains slot model in the live view:

defp assign_form(%{assigns: %{slot: slot, current_user: current_user}} = socket) do
    form =
      AshPhoenix.Form.for_create(
        Lngx.DemandAggregation.UserDemand.Demand,
        :create,
        as: "create_demand",
        actor: current_user, slot
      )

    assign(socket, form: to_form(form))
  end

The error i am getting is: [error] Unable to Create Demand: [slots: {"is required", []}]
2. Later i thought actor can be only one. So i tried to manually put slot in the map while inserting by passing slot_id from assigns. Still i am getting the similar error like above: [error] Unable to Create Demand: [slots: {"is required", []}]

Here the function to for create in :live_view:

def handle_event("save", %{"create_demand" => create_demand}, socket) do
    # Logger.warning("Socket Assigns: #{inspect(socket.assigns)}")
    create_demand_with_slot_id = Map.put(create_demand, :slots_id, socket.assigns.id)

    case AshPhoenix.Form.submit(socket.assigns.form, params: create_demand_with_slot_id) do
      {:ok, _demand} ->
        socket
        |> put_flash(:info, "Created Demand Succesfully")
        |> push_patch(to: socket.assigns.patch)

        {:noreply, socket}

      {:error, form} ->
        Logger.error("Unable to Create Demand: #{inspect(form.errors)}")
        {:noreply, assign(socket, form: form)}
    end
  end

How can I solve this? Any help or references would be greatly appreciated.
Thank You.

This isn’t valid elixir syntax, and even if it was, there can be only one actor as you pointed out.

For your second approach to work, you’ll need to ensure that your action accepts slots_id.

i.e

create :create do
  accept [:booked_volume, :slots_id]
end

Or perhaps you’d want to modify your default_accept:

default_accept [:booked_volume, :slots_id]

Thank you for the reply, now i got it. But, is the there any way to pass slots_id from the params into theAshPhoenix.Form.for_create without having input field.?

You could use a private argument. Private arguments must be set with Ash.Changeset.set_argument.

i.e

# in your action
argument :slots_id, :uuid, public?: false
# in your form
AshPhoenix.Form.submit(...., before_submit: fn changeset -> 
  Ash.Changeset.set_argument(changeset, :slots_id, socket.assigns.id)
end)

Thank you.