Hi guys, I wonder if I am missing some conventions for the select_tag. In fact, while the f.text_field is automatically naming the html text field form_name[field_name] just using the :field_name convention, like: <div> <%= f.label :data_point_id %> <%= f.text_field :data_point_id %> </div> if I try to display a select_tag for the same attribute I have to use a select_tag, since there is no f.select_tag, I have to include the form_name inside the select_name, like this: <div> <%= f.label :data_point_id %> <%= select_tag ''data_point_tab[data_point_id]'', options_from_collection_for_select(DataPoint.all, ''id'', ''name'')%> </div> Is there a better way to do this or am I doing correct? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 16 May 2011 09:14, johnlucas <gianluca.trombetta-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I wonder if I am missing some conventions for the select_tag. > > In fact, while the f.text_field is automatically naming the html text > field form_name[field_name] just using the :field_name convention, > like: > > <div> > <%= f.label :data_point_id %> > <%= f.text_field :data_point_id %> > </div> > > if I try to display a select_tag for the same attribute I have to use > a select_tag, since there is no f.select_tag, I have to include the > form_name inside the select_name, like this: > > <div> > <%= f.label :data_point_id %> > <%= select_tag ''data_point_tab[data_point_id]'', > options_from_collection_for_select(DataPoint.all, ''id'', ''name'')%> > </div> > > Is there a better way to do this or am I doing correct?You want: f.select Generally, the standalone form helpers have ''_tag'' at the end of their name, and the FormBuilder-based ones leave the ''_tag'' off. AFAIK, every ''_tag'' form helper has a corresponding FormBuilder one. Chris -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
ops, that was very easy... thanks! On May 16, 11:33 am, Chris Mear <chrism...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 16 May 2011 09:14, johnlucas <gianluca.trombe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > I wonder if I am missing some conventions for the select_tag. > > > In fact, while the f.text_field is automatically naming the html text > > field form_name[field_name] just using the :field_name convention, > > like: > > > <div> > > <%= f.label :data_point_id %> > > <%= f.text_field :data_point_id %> > > </div> > > > if I try to display a select_tag for the same attribute I have to use > > a select_tag, since there is no f.select_tag, I have to include the > > form_name inside the select_name, like this: > > > <div> > > <%= f.label :data_point_id %> > > <%= select_tag ''data_point_tab[data_point_id]'', > > options_from_collection_for_select(DataPoint.all, ''id'', ''name'')%> > > </div> > > > Is there a better way to do this or am I doing correct? > > You want: > > f.select > > Generally, the standalone form helpers have ''_tag'' at the end of their > name, and the FormBuilder-based ones leave the ''_tag'' off. AFAIK, > every ''_tag'' form helper has a corresponding FormBuilder one. > > Chris-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.