Edward Scott
Edward Scott
AEAsh Elixir
Created by Edward Scott on 4/10/2023 in #support
How to determine the cause of a form validation error
That makes sense. Your suggestion worked. Thank you.
9 replies
AEAsh Elixir
Created by Edward Scott on 4/10/2023 in #support
How to determine the cause of a form validation error
I just want the variables to be owned by the 'compenent'. I will change to :map.
9 replies
AEAsh Elixir
Created by Edward Scott on 4/10/2023 in #support
How to determine the cause of a form validation error
and
# interacting with the resource programmatically.
code_interface do
define_for XrtConfiguratorApp.Template
define :create, action: :create
define :read_all, action: :read
define :update, action: :update
define :destroy, action: :destroy
define :get_by_id, args: [:id], action: :by_id
end

actions do
# Exposes default built in actions to manage the resource
defaults [:create, :read, :update, :destroy]

# Defines custom read action which fetches post by id.
read :by_id do
# This action has one argument :id of type :uuid
argument :id, :uuid, allow_nil?: false
# Tells us we expect this action to return a single result
get? true
# Filters the `:id` given in the argument
# against the `id` of each element in the resource
filter expr(id == ^arg(:id))
end
end

# Attributes are simple pieces of data that exist in your resource
attributes do
# Add an autogenerated UUID primary key called `:id`.
uuid_primary_key :id

attribute :name, :string do
allow_nil? false
end

attribute :description, :string do
allow_nil? false
end

attribute :default_value, :string

end

relationships do
belongs_to :component, XrtConfiguratorApp.Template.Component do
attribute_writable? true
end
end

end
# interacting with the resource programmatically.
code_interface do
define_for XrtConfiguratorApp.Template
define :create, action: :create
define :read_all, action: :read
define :update, action: :update
define :destroy, action: :destroy
define :get_by_id, args: [:id], action: :by_id
end

actions do
# Exposes default built in actions to manage the resource
defaults [:create, :read, :update, :destroy]

# Defines custom read action which fetches post by id.
read :by_id do
# This action has one argument :id of type :uuid
argument :id, :uuid, allow_nil?: false
# Tells us we expect this action to return a single result
get? true
# Filters the `:id` given in the argument
# against the `id` of each element in the resource
filter expr(id == ^arg(:id))
end
end

# Attributes are simple pieces of data that exist in your resource
attributes do
# Add an autogenerated UUID primary key called `:id`.
uuid_primary_key :id

attribute :name, :string do
allow_nil? false
end

attribute :description, :string do
allow_nil? false
end

attribute :default_value, :string

end

relationships do
belongs_to :component, XrtConfiguratorApp.Template.Component do
attribute_writable? true
end
end

end
I get a validation error: [field: :variables, message: \"at index 1 is invalid\", index: 1] from the validate in my update handler calling AshPhoenix.Form.submit(AshPhoenix.Form.validate(socket.assigns.update_form, form)) The form is defined using:
form = comp |> AshPhoenix.Form.for_update(:update,
api: XrtConfiguratorApp.Template,
forms: [
variables: [
resource: Variable,
data: comp.variables,
update_action: :update,
type: :list
]]) |> to_form()
form = comp |> AshPhoenix.Form.for_update(:update,
api: XrtConfiguratorApp.Template,
forms: [
variables: [
resource: Variable,
data: comp.variables,
update_action: :update,
type: :list
]]) |> to_form()
I can't spot the cause of the error. Any suggestion on how to proceed?
9 replies