Hi, How do I get a value out of a form block eg. <% 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. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think, you trying to implement something like observe field on name
to get age.
You can
<%= observe_field ''order_name'',
      :frequency => 1,
      :update => "UPDATE_SPAN/DIV/TEXTFIELD_ID_OF_AGE",
      :url => {:action => ''YOUR_ACTION_TO_GET_AGE
''}%>
For more info on this ajax, refer this:
http://wiki.rubyonrails.org/rails/pages/observe_field+-+Passing+Parameters
Regards.
On Aug 13, 11:52 am, "nigel.bris"
<nigel.b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> How do I get a value out of a form block
> eg.
> <% 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.
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi Carolene, Unfortunately, I have not explained myself properly... Great answer though! 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 %> On Aug 13, 5:18 pm, Carolene <kiran.sou...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I think, you trying to implement something like observe field on name > to get age. > You can > <%= observe_field ''order_name'', > :frequency => 1, > :update => "UPDATE_SPAN/DIV/TEXTFIELD_ID_OF_AGE", > :url => {:action => ''YOUR_ACTION_TO_GET_AGE ''}%> > > For more info on this ajax, refer this:http://wiki.rubyonrails.org/rails/pages/observe_field+-+Passing+Param... > > Regards. > > On Aug 13, 11:52 am, "nigel.bris" <nigel.b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > How do I get a value out of a form block > > eg. > > <% 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. > > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi -- On Sun, 12 Aug 2007, nigel.bris wrote:> > Hi, > > How do I get a value out of a form block > eg. > <% 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 believe in edge you can do: form_block.object, and in non-edge you can at least do form_block.object_name. I might be wrong about the edge/non-edge distinction; it''s based on some quick trials, where <%debug f.object %> got me nil in non-edge. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---