Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render a partial inside ActiveAdmin edit page

I need to render a partial inside ActiveAdmin page. I am trying something like:

  form(:html => { :multipart => true }) do |f|
    f.inputs "Описание товара #{f.object.name if f.object.name}" do
      f.input :name, :required => true
      f.input :brand
      f.input :category
      f.input :created_at, :wrapper_html => { :class => 'inline-list' }
      f.input :updated_at, :wrapper_html => { :class => 'inline-list' }

      f.actions
    end
    content do
      render partial: 'fancybox'
    end
  end

But it doesn't work. My partial contents replace the form contents. I guess I need a right wrapper element for render but using panel was no success. Any thoughts?

like image 337
leemour Avatar asked Sep 26 '13 09:09

leemour


2 Answers

Try to use render with f.template:

form(:html => { :multipart => true }) do |f|
  f.inputs "Описание товара #{f.object.name if f.object.name}" do
    f.input :name, :required => true
    f.input :brand
    f.input :category
    f.input :created_at, :wrapper_html => { :class => 'inline-list' }
    f.input :updated_at, :wrapper_html => { :class => 'inline-list' }

    f.actions
  end
  f.inputs "Fancybox" do
    f.template.render partial: 'fancybox'
  end
end
like image 91
Oleg Haidul Avatar answered Nov 06 '22 03:11

Oleg Haidul


You can also go with following

f.render partial: 'folder/partial page' unless f.object.new_record?

like image 41
Ankit Varshney Avatar answered Nov 06 '22 03:11

Ankit Varshney