", '@item') %>

Hi,
Is it possible to do something like this multiple levels deep as shown
in the subject?

<% for @order in @orders %>

<%= text_field(“order[]”, ‘name’) %>

<% for @item in @order.items %>

<%= text_field(“order[item[]]”, ‘name’) %>

Seems like something along these lines should work. I’ve tried a
couple different ways, but I can’t guess my way through this. The
documentation doesn’t mention anything, so I’m guessing it’s not
implemented? I’m looking at the source now, so maybe that will help.

Any thoughts?
Thanks,
Ben

On 11/23/05, Ben A. [email protected] wrote:

<%= text_field("order[item[]]", 'name') %>

Seems like something along these lines should work. I’ve tried a
couple different ways, but I can’t guess my way through this. The
documentation doesn’t mention anything, so I’m guessing it’s not
implemented? I’m looking at the source now, so maybe that will help.

try text_field_tag. text_field expects an active record model.


rick
http://techno-weenie.net

Not too sure what you mean here… Do you mean to pass in exactly the
name and id that I want? I figured I could that if I wanted to. I
was looking for something that works seamlessly and that loads back in
via an incoming request. Seems like it would just take extending
what’s already there for the one level.

Unless I’m missing what you’re saying and there’s some magic to
text_field_tag that I’m missing?

-Ben

On 11/23/05, Ben A. [email protected] wrote:

Not too sure what you mean here… Do you mean to pass in exactly the
name and id that I want? I figured I could that if I wanted to. I
was looking for something that works seamlessly and that loads back in
via an incoming request. Seems like it would just take extending
what’s already there for the one level.

Unless I’m missing what you’re saying and there’s some magic to
text_field_tag that I’m missing?

-Ben

Actually, you had it right. I went to check the docs :slight_smile:

http://rails.rubyonrails.com/classes/ActionView/Helpers/FormHelper.html

Apparently you can do <%= text_field ‘order’, ‘name’, :index => 1 %>
which will give you an id like order[1][name]. Do your looping like
this:

<% @orders.each_with_index do |order, order_index| -%>

Beyond that I’m not quite sure. Never had to do this actually.


rick
http://techno-weenie.net