Double nested forms #478

Mansari opened this Issue Sep 14, 2011 · 2 comments


None yet

4 participants

Mansari commented Sep 14, 2011


I am using ActiveAdmin had_many form helper to build a form for two has_many associations
Project-->Task-->Notes for example.

Has anyone used this before? I am using it and the forms gets generated just fine, HOWEVER, if I try to add a new project and on the same page add a new task and a new note, the project and task gets saved, but not the note.

I tried doing my own form/controller and it works fine. Is this something that is a bug or a 'feature' that needs to be configured in AA own controllers?



I have only used this in a limited capacity - i.e., build the references on the page load (limited to 3 for instance), but not an unlimited amount of them.

Note this is typed up from memory, but very close to working:

ActiveAdmin.register Post do

    form do |f|
        3.times { }
        f.inputs "Post Info" do

        f.inputs "Photos" do
            f.semantic_fields_for :photos do |photo|
                if photo.object.new_record?
                    photo.input :photo, :as => :file
                    text_node ( '<label>Photo</label>' )
                    text_node ( link_to( File.basename( photo.object.path ), photo.object.url ) )


This approach always gives you 3 new upload fields, in addition to however many photos have already been attached to the post.

@pcreux pcreux closed this Oct 13, 2011
TMaYaD commented Oct 21, 2011

I have faced similar issue and tried to debug it. The problem is with how the add Task and Add Note buttons work. The generate the inputs with timestamp as an index. As a result, the add note generates a different time stamp than the one being used by the task field generated with add task.
I'll try to fix the issue and submit a pull request.
Can someone please reopen this issue until it is solved.

@TMaYaD TMaYaD added a commit to TMaYaD/active_admin that referenced this issue Oct 21, 2011
@TMaYaD TMaYaD fixed #478 modified the place holder for NEW_RECORD to contain the mo…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment