Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

semantic_form_for without resource with multiple input not working

i got some problem with a resourceless form inside activeadmin page:

ActiveAdmin.register_page 'TestDashboard' do
  menu :label => 'TestDashboard'

  content title: 'TestDashboard' do

    columns do
      column do
        div do
          semantic_form_for 'dashboard', :url => '#' do |f|
            f.inputs :name => 'Configure', :class => 'inputs' do
              f.input :target
              f.input :name
            end
          end
        end
      end
    end
  end # content
end

only the last field (name) is shown. The resulting html is:

<form novalidate="novalidate" method="post" class="formtastic dashboard" action="#" accept-charset="UTF-8">
  <div style="margin:0;padding:0;display:inline"><input type="hidden" value="✓" name="utf8">
    <input type="hidden" value="3424234blabla" name="authenticity_token">
  </div>
  <fieldset class="inputs">
      <legend>
        <span>Configure</span>
      </legend>
      <ol>
        <li id="dashboard_name_input" class="string input required stringish">
          <label for="dashboard_name" class="label">Name<abbr title="required">*</abbr></label>
          <input type="text" name="dashboard[name]" id="dashboard_name">
        </li>
      </ol>
  </fieldset>
</form>

Thank you in advance.

like image 435
Zen Avatar asked May 30 '14 12:05

Zen


1 Answers

You should put this in a partial:

In views/admin/testdashboard/_configure_form.html.erb

<%= semantic_form_for 'dashboard', :url => '#' do |f| %>
  <%= f.inputs :name => 'Configure', :class => 'inputs' do %>
    <%= f.input :target %>
    <%= f.input :name %>
  <% end %>
<% end %>

In your TestDashboard.rb

ActiveAdmin.register_page 'TestDashboard' do
  menu :label => 'TestDashboard'

  content title: 'TestDashboard' do
    columns do
      column do
        render "configure_form"
      end
    end
  end # content
end

And it should work nicely then :)

like image 151
rorofromfrance Avatar answered Sep 19 '22 06:09

rorofromfrance