开发者

Rails form processing

I have a form with a store number (collection select box), date (3 select boxes), and a list of items with a quantity field beside each item. I have been able to pas开发者_JAVA百科s the items and quantities as an array of hashes, but I can't get the date and store numbers in because I can't seem to change their name to include the [].

Here's the code

<% form_for(@credit) do |f| %>
<% stores = Store.find(:all, :conditions => { :active => true }, :order => :storeNum) %>
Store Number<%= f.collection_select :storeNum, stores, :storeNum, :storeNum %>
<br /><%= f.date_select :credDate %>
<table>
  <tr>
    <th>Quanity</th>
    <th>Item Number</th>
    <th>Name</th>
  </tr>

<% @items.each do |item| %>
  <tr>
    <td>
        <%= f.text_field ( :quantity, :name => "credit[][quantity]", :size => 3 )  %>
        <%= f.hidden_field :item, :name => "credit[][itemNum]", :value => item.itemNum %>
    </td>
    <td><%=h item.itemNum %></td>
    <td><%=h item.name %></td>
  </tr>
<% end %>
  <tr><td colspan="3">
    <%= f.submit 'Submit' %></td>
  </tr>
</table>
<% end %>

Any help is surely appreciated. I've been working on this two days.


Have you considered simple HTML inputs?

<input type="text" name="credit[][quantity]" size="3" id="quantity"></input>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜