zskreisz
zskreisz
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
soft delete - identity issue
Thanks, will try that!
4 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
yeah, thanks, this is not a framework issue!
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
Oh, is it related to that? It's my custom code, but I'll switch it off and try saving without it, and if it is causing the error I'll handle it. Tl;dr, I have a generic versioning implementation.
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
now i could save one price for a user, and it is preloaded with the form on edit, now without modifying anything, upon trying to save the form, I get:
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
yeah, that helped, thanks.
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
to something like: %{"_target" => ["form", "name"], "form" =>
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
as the pattern changed
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
I believe, the function:
@impl true
def handle_event("validate", %{"user" => user_params}, socket) do
{:noreply, assign(socket, form: AshPhoenix.Form.validate(socket.assigns.form, user_params))}
end
@impl true
def handle_event("validate", %{"user" => user_params}, socket) do
{:noreply, assign(socket, form: AshPhoenix.Form.validate(socket.assigns.form, user_params))}
end
is not good now
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
now I have a validation issue:
* (FunctionClauseError) no function clause matching in OrcaLinkWeb.UserLive.FormComponent.handle_event/3
(orca_link 0.1.0) lib/orca_link_web/live/forms/user_live/form_component.ex:185: OrcaLinkWeb.UserLive.FormComponent.handle_event("validate", %{"_target" => ["form", "name"], "form" => %{"user_name" => "JD", "tolmacs" => "false", "car" => "false", "_unused_vatstatus" => "", "timezone" => "", "default_sms" => "false", "_unused_post_code" => "", "country_code" => "", "primary_phone_number" => "adwákowd", "_unused_user_name" => "", "_unused_secondary_phone_number" => "", "_unused_default_sms" => "", "_unused_address" => "", "vendor_invoice_folder_link" => "", "city" => "", "_unused_languages" => "", "_unused_tolmacs" => "", "_unused_primary_phone_number" => "", "comment" => "", "billi
* (FunctionClauseError) no function clause matching in OrcaLinkWeb.UserLive.FormComponent.handle_event/3
(orca_link 0.1.0) lib/orca_link_web/live/forms/user_live/form_component.ex:185: OrcaLinkWeb.UserLive.FormComponent.handle_event("validate", %{"_target" => ["form", "name"], "form" => %{"user_name" => "JD", "tolmacs" => "false", "car" => "false", "_unused_vatstatus" => "", "timezone" => "", "default_sms" => "false", "_unused_post_code" => "", "country_code" => "", "primary_phone_number" => "adwákowd", "_unused_user_name" => "", "_unused_secondary_phone_number" => "", "_unused_default_sms" => "", "_unused_address" => "", "vendor_invoice_folder_link" => "", "city" => "", "_unused_languages" => "", "_unused_tolmacs" => "", "_unused_primary_phone_number" => "", "comment" => "", "billi
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
I couldn't figure that direct_control, or append_and_remove could have been an issue
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
but it didn't work at first, and tried to patch, and patch, and patch
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
not just plain AI
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
yeah, no, I first tried to go with the documentations
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
so if i simply do this:
defp assign_form(%{assigns: %{user: user}} = socket) do
form =
if user do
# Pass the form_opts to for_update
AshPhoenix.Form.for_update(user, :update_with_supplier_price) # Use the action that manages the relationship
else
# Pass the form_opts to for_create
AshPhoenix.Form.for_create(OrcaLink.Accounts.User, :create) # Ensure :create action also handles supplier_prices if needed
end

assign(socket, form: to_form(form))
end
defp assign_form(%{assigns: %{user: user}} = socket) do
form =
if user do
# Pass the form_opts to for_update
AshPhoenix.Form.for_update(user, :update_with_supplier_price) # Use the action that manages the relationship
else
# Pass the form_opts to for_create
AshPhoenix.Form.for_create(OrcaLink.Accounts.User, :create) # Ensure :create action also handles supplier_prices if needed
end

assign(socket, form: to_form(form))
end
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
yeah, kinda relying too much on ai...
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
@impl true def update(assigns, socket) do {:ok, socket |> assign(assigns) |> assign_form() |> assign_select_options() } end
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
defp assign_form(%{assigns: %{user: user}} = socket) do
# Define common form options, including nested form config
form_opts = [
api: OrcaLink.Accounts, # Assuming your User resource is in this API
forms: [
# Configure the supplier_prices relationship
supplier_prices: [
resource: OrcaLink.Accounts.SupplierPrice, # The resource for the nested form
create_action: :create, # Action to use for new supplier prices
update_action: :update, # Action to use for existing supplier prices
# You might also need `destroy_action: :soft_delete` if you allow removal
destroy_action: :soft_delete
]
# Add other nested forms here if needed
],
as: "user"
]

form =
if user do
# Pass the form_opts to for_update
AshPhoenix.Form.for_update(user, :update_with_supplier_price, form_opts) # Use the action that manages the relationship
else
# Pass the form_opts to for_create
AshPhoenix.Form.for_create(OrcaLink.Accounts.User, :create, form_opts) # Ensure :create action also handles supplier_prices if needed
end

assign(socket, form: to_form(form))
end
defp assign_form(%{assigns: %{user: user}} = socket) do
# Define common form options, including nested form config
form_opts = [
api: OrcaLink.Accounts, # Assuming your User resource is in this API
forms: [
# Configure the supplier_prices relationship
supplier_prices: [
resource: OrcaLink.Accounts.SupplierPrice, # The resource for the nested form
create_action: :create, # Action to use for new supplier prices
update_action: :update, # Action to use for existing supplier prices
# You might also need `destroy_action: :soft_delete` if you allow removal
destroy_action: :soft_delete
]
# Add other nested forms here if needed
],
as: "user"
]

form =
if user do
# Pass the form_opts to for_update
AshPhoenix.Form.for_update(user, :update_with_supplier_price, form_opts) # Use the action that manages the relationship
else
# Pass the form_opts to for_create
AshPhoenix.Form.for_create(OrcaLink.Accounts.User, :create, form_opts) # Ensure :create action also handles supplier_prices if needed
end

assign(socket, form: to_form(form))
end
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
I'll try this
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
I don't really get what you mean, where do I have to add this?
51 replies
AEAsh Elixir
Created by zskreisz on 5/4/2025 in #support
nested form issue
I also added the render function's <.input_for ... if that is what you mean
51 replies