Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Rails] text_field and hidden_field don't work in a for loop?


  • From: jarkko at jlaine.net (Jarkko Laine)
  • Subject: [Rails] text_field and hidden_field don't work in a for loop?
  • Date: Tue Jan 18 11:26:31 2005

Hi,

I noticed this strange behavior in one of my templates:

   <% for shoe in @product.shoes %>
   <tr>
     <td headers="size"><%= shoe.size %></td>
     <td headers="amount">
       <%= start_form_tag :action => "update_shoe" %>
       <%= hidden_field "shoe", "id" %>
       <%= text_field("shoe", "amount", "size" => 5, "maxlength" => 5) %>
       <input type="submit" value="Update" />
       <%= end_form_tag() %>
     </td>
     <td><%= link_to "Delete", :action => "del_shoe", :id => shoe.id 
%></td>
   </tr>
   <% end %>

Results in:
   <tr>
     <td headers="size">46</td>
     <td headers="amount">
       <form action="/admin/update_shoe" method="post">
       <input id="shoe_id" name="shoe[id]" type="hidden" value="" />
       <input id="shoe_amount" maxlength="5" name="shoe[amount]" 
size="5" type="text" value="0" />
       <input type="submit" value="Update" />
       </form>

     </td>
     <td><a href="/admin/del_shoe/1">Delete</a></td>
   </tr>

Notably, hidden_field and text_field don't fill in the existing values 
(value="0" in the text field is wrong). However in link_to the shoe id 
is working fine.

Any way I can get around this?

TIA,
//jarkko

--
Jarkko Laine
http://jlaine.net
http://odesign.fi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2363 bytes
Desc: not available
Url : http://one.textdrive.com/pipermail/rails/attachments/20050118/44dccab6/smime.bin