Trestle: How to add an inner form for relation

89 Views Asked by At

I am trying out Trestle for admin and sadly the documentation isn't helping me out. I am trying to add tabs to my form to show the relationships, which is working fine with

Trestle.resource(:shows) do
  menu do
    item :shows, icon: "fa fa-star", group: :show_management
  end

  form do |show|
    tab :classes do
      table show.participents, admin: :participents do
        column :full_name

        actions
      end
    end
   end
 end
end

However, I am struggling to find a way to add a form with select box or something to add an additional user. I tried nesting a form and using the concat, however these return a string of the object.

Grateful to any suggestions, I would really like to make a go of using this rather than building yet another admin dashboard from scratch.

1

There are 1 best solutions below

0
Sam Pohlenz On

I'd recommend using Cocoon for your nested form fields. There are some instructions for this that are a little buried within the Trestle issue tracker here: https://github.com/TrestleAdmin/trestle/issues/19#issuecomment-347499096

First-class support for this is still planned but I've had way less time this year to work on it than I had hoped.

Another option would be to create a new admin resource for your child model, create the form within it with dialog: true and then link to it from the parent resource.

You can find an example of this approach here: https://github.com/TrestleAdmin/trestle/issues/64#issuecomment-356894189