Note that there are some explanatory texts on larger screens.

plurals
  1. POActiveAdmin: Displaying form as an IFRAME within another form
    text
    copied!<p>I am developing an application with a Gallery model and an Images model, where each gallery has_and_belong_to_many images.</p> <p>I'm currently developing the form for creating/editing a gallery. From this form, I would like users to be able to both add existing images and upload new images to the gallery. After much mucking about, I was able to use the Rails "nested model forms" functionality to achieve this, but the end result was unsatisfactory from a UI perspective.</p> <p>I've realized that what I really need is an IFRAME in my gallery form that contains an image form. How can I include the image form as an IFRAME without all the surrounding markup that is normally rendered along with the form (e.g., the header, the title bar, and the footer)? Note in the code below that I am already using ":layout => false" when I call "render" in my "new_iframe" controller method.</p> <p>Here is my Image resource file:</p> <pre><code>ActiveAdmin.register Image do controller.authorize_resource scope_to :current_admin_user collection_action :new_iframe, :method =&gt; :get do @image = Image.new render :action =&gt; :new, :layout =&gt; false end controller do ... end index do column :title do |image| link_to image.title, edit_admin_image_path(image) end column :image do |image| image_tag(image.thumb_path, :alt =&gt; "") end column :created_at column :updated_at default_actions end form :html =&gt; { :enctype =&gt; "multipart/form-data" } do |a| a.inputs "Image", :multipart =&gt; true do a.input :title a.input :asset, :as =&gt; :file end a.buttons end end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload