Form Blocks


How do I get a value out of a form block
<% form_for :order do |form_block| %>
<%= form_block.text_field :name, :size => 40 %>
<% end %>

If within that block I wanted to get the value of an attribute like
age, how cold you get that from the form_block instance? eg
form_block.age (i realise this does not work). I could just do
@order.age but I need to check from a helper where the block is only
sen to it.


I think, you trying to implement something like observe field on name
to get age.
You can
<%= observe_field 'order_name',
      :frequency => 1,
      :url => {:action => 'YOUR_ACTION_TO_GET_AGE '}%>

For more info on this ajax, refer this:


Hi Carolene,

Unfortunately, I have not explained myself properly... Great answer

What I meant is:-
<% form_for :order do |form_block| %>
<%= form_block.text_field :name, :size => 40 %>
<% some code here that could return the value of age that refers to
age via form_block (not @order) eg form_block.age %>
<% end %>

Hi --