zimt28
zimt28
AEAsh Elixir
Created by zimt28 on 5/31/2023 in #support
Nested forms questions
I'm building a nested form with a single resource that can be nested as many times as the user wants. I cannot use manage_relationship/4 in my case so I'm using after_action hooks that don't seem to work with auto?: true. 1. Is there a way to get a behaviour similar to auto?: true? I'm currently specifying the forms option using a function that just generates recursive options for n levels deep and results in
forms: [
direct_child_listings: [
type: :list,
resource: App.Listings.Listing,
create_action: :create,
forms: [
direct_child_listings: [
# ...
forms: [
direct_child_listings: [
type: :list,
resource: App.Listings.Listing,
create_action: :create
]
forms: [
direct_child_listings: [
type: :list,
resource: App.Listings.Listing,
create_action: :create,
forms: [
direct_child_listings: [
# ...
forms: [
direct_child_listings: [
type: :list,
resource: App.Listings.Listing,
create_action: :create
]
2. Using Form.add_form, is there a way to get the path of a newly created form? In this case I could update the form to solve question 1. 3. It looks like all form levels track the params of their nested forms. When updating a form I cannot see the change on my page unless I run something like add_form again – this seems to update all params. Is there a way to refresh the params manually?
Form.update_form(socket.assigns.form, path, fn form ->
Form.validate(form, %{"type" => "type", "subtype" => subtype})
end)
Form.update_form(socket.assigns.form, path, fn form ->
Form.validate(form, %{"type" => "type", "subtype" => subtype})
end)
16 replies
AEAsh Elixir
Created by zimt28 on 5/29/2023 in #support
Access parent result using manage_relationship
Is there a way to access the parent result when using manage_relationship/4? I'm currently using a hook to generate related records but I'm wondering if there is a better way.
3 replies
AEAsh Elixir
Created by zimt28 on 5/23/2023 in #support
Fetching descendants in calculation
I've created a listings resource/table which is nestable via a parent_listing_id attribute. In a calculation I want to find all descendants for a listing, what's the best way to do this?
7 replies