form_remote_for, reloaded

Andor Greißl wrote:

Iterating in small steps to AJAX, the next iteration was:

  <%form_remote_for :time_record, :url => { :action => "add_time_record"
} do |f| %>
    <% f.date_select(:day, :disabled => true, :order => [:day, :month])
    <td><%= f.date_select(:day, :order => [:day, :month]) %></td>
    <td><%= f.collection_select(:user_id, @users, :id, :login_name)
    <td><%= f.collection_select(:project_id, @projects, :id, :name)
    <td><%= f.text_field :quantity, :size => 4 %></td>
    <td><%= f.text_field :description, :size => 50 %></td>
    <td><%= submit_tag "Zeit Erfassen" %></td>
  <% end %>

Which did not work.

This'll work if you instead write something like:

<tr id="time_record">
<% fields_for :time_record do |f| %>
<td><%= f.date_select :day, :disabled => true, :order => [:day, :month] %></td>
<td><%= f.date_select :day, :order => [:day, :month] %></td>
<td><%= f.collection_select :user_id, @users, :id, :login_name %></td>
<td><%= f.collection_select :project_id, @projects, :id, :name %></td>
<td><%= f.text_field :quantity, :size => 4 %></td>
<td><%= f.text_field :description, :size => 50 %></td>
<td><%= submit_to_remote :commit, "Zeit Erfassen", :submit => :time_record,
                          :url => {:action => "add_time_record"} %></td>
<% end %>

In my opinion, form_for and form_remote_for should behave the same way.

They do. You're lucky your first form_for version worked at all.