开发者

form is not ended properly inside the table that causes update method

Here is my code, i have wasted lot of time on this but still did not get the answer.Form ended in the same row where it started and because of this submit method is not adding the checkbox values in database.please help?

< table>
  <% pos = 0%>
  <% @accounts.each do |myacc| %>
    <% if @accounts.length  == pos +1 %>
      <tr class="last">
    <% else%>
      <tr>
    <% end %> <!-- end of if tag -->
    <td class="position"><%= pos += 1%>.</td>
    <td ><%= myacc.name %>< /td>
    < % form_for(:account,:html =>{:method =>:put,:id =>"editAccountForm_"+pos.to_s,:multipart => true}) do|f|%>
      <td>
        <% if myacc.place_matching == "1" %>
          <input type="checkbox" id=place_matching value=1 checked="checked"  />
        <% else %> 
          <input type="checkbox" id=place_matching value=0  />
        <% end %> <!-- end of if tag -->                                                 
      </td>
      <td> 
        <% if myacc.data_pulling == "1" %>
          <input type="checkbox" id="data_pulling" value=1 checked="checked" />
        <% else %> 
          <input type="checkbox"  id="data_pulling"  value=0  />
        <% end %> <!-开发者_高级运维- end of if tag -->
      </td>
      <td>
        <a class="gray-button gray-whitebg" href="#" onclick="getElementById('editAccountForm_<%= pos%>').submit();return false;" />ADD</a>
      </td>
    <% end %> <!-- end of form tag -->
    </tr>
  <% end %> 
</table>


In rails 3 you always have to use <%= %> form, also for blocks. So write

<%= form_for ...

I see you use the form_for, but then not use f at all. Why not use f.check_box ? See documentation. Or use form_tag and then use check_box_tag. See documentation.

You should be using more of the helpers rails gives you.


Please paste your complete form..

please take you form out from your table..

hope this will help

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜