0

I have the following form(truncated)

    <%= form_for(daysevent, :html => { :class => "form-inline"} ) do |f| %>
    <fieldset>
    <div class="control-group">
        <%= f.label :start_date, :class => 'control-label' %>
        <div class="controls">
          <%= f.text_field :start_date, 'data-behavior' => 'datepicker1' %>
        </div>
      </div>
      <div class="control-group">
        <%= f.label :end_date, :class => 'control-label' %>
        <div class="controls">
          <%= f.text_field :end_date, 'data-behavior' => 'datepicker2' %>
        </div>
      </div>
    Locations for this date:<br/>
    <% daysevent.event.locations.each do |l|%>         
        <%= check_box_tag 'location_ids[]', l.id, true -%><%= h l.name -%><br/>    
    <% end %> 
    <%= f.submit 'Create Date' %>
    </fieldset>
    <% end %> 

I'm trying to get the list of location checkboxes to come through in an array of IDs but its not working, in my create method return render :text => params[:days_event] is just returning start_date and end_date. I've only been doing rails for a few months so its probably something simple but all help his appreciated.

1 Answer 1

1

You are not sending values of checkboxes in the params[:days_event] but in params[:locations_ids]. You can check debug output from rails server and you will see parsed params hash.

If you want to send them along then change the checkboxes to:

<%= check_box_tag "days_event[location_ids][]" .... %>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.