Is there any way to add a ''style'' attribute to a tag like start_form_tag ? Chris
Chris, You should be able to do something like: <%= start_form_tag :class => ''styleYouWant'' %> On 8/16/05, snacktime <snacktime-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is there any way to add a ''style'' attribute to a tag like start_form_tag ? > > Chris > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- - Frank FrankManno.com <a href="http://www.spreadfirefox.com/?q=affiliates&id=2496&t=1">Get Firefox!</a>
On 8/16/05, Frank Manno <frankmanno-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Chris, > > You should be able to do something like: > > <%= start_form_tag :class => ''styleYouWant'' %>That''s what I thought also, but it just appends "?class=styleYouWant" onto the action url. I''m just wrapping different elements inside div tags, but that doesn''t always work. For instance it would be nice to be able to add a :confirm => ''Are you sure?'' to form_tag like I can with link_to. Or maybe there is a way and I just haven''t figured it out, that''s entirely possible. Chris
If you''re using the scaffolding stuff, it has two hash parameters in a row. Ruby seems to want to squish those together into the first one: start_form_tag :action => ''create'', :class => ''joe'' Sees the first parameter as having two keys, action and class, and the second parameter (the "options" one) as having nothing. "&class=joe" is then appended to the url since it is part of the first parameter. Doing: start_form_tag :action => ''create'', {:class => ''joe''} Is a syntax error, as ruby sees the {} and assumes a block, not a hash. Here''s how to explicitly pass an inline hash successfully to start_form_tag, and have ruby put the first value into the first parameter and the second into the second parameter: start_form_tag(({:action => ''create''}), ({:class => ''joe''})) I''m sure there''s a more elegant way to do this, but this is what I could get working for me. Can anybody make this pretty and still have it work as expected? On 8/16/05, Frank Manno <frankmanno-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Chris, > > You should be able to do something like: > > <%= start_form_tag :class => ''styleYouWant'' %> > > On 8/16/05, snacktime <snacktime-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Is there any way to add a ''style'' attribute to a tag like start_form_tag ? > > > > Chris > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > - Frank > FrankManno.com > > <a href="http://www.spreadfirefox.com/?q=affiliates&id=2496&t=1">Get > Firefox!</a> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Brock Weaver http://www.circaware.com
On 8/16/05, Brock Weaver <brockweaver-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you''re using the scaffolding stuff, it has two hash parameters in a > row. Ruby seems to want to squish those together into the first one: > > start_form_tag :action => ''create'', :class => ''joe'' > > Sees the first parameter as having two keys, action and class, and the > second parameter (the "options" one) as having nothing. "&class=joe" > is then appended to the url since it is part of the first parameter.That''s what I thought was happening but I didn''t know how to get around it. Thanks for the info! Chris
On Aug 16, 2005, at 6:41 PM, Brock Weaver wrote:> If you''re using the scaffolding stuff, it has two hash parameters in a > row. Ruby seems to want to squish those together into the first one: > > start_form_tag :action => ''create'', :class => ''joe'' > > Sees the first parameter as having two keys, action and class, and the > second parameter (the "options" one) as having nothing. "&class=joe" > is then appended to the url since it is part of the first parameter. > > Doing: > > start_form_tag :action => ''create'', {:class => ''joe''} > > Is a syntax error, as ruby sees the {} and assumes a block, not a hash. > > Here''s how to explicitly pass an inline hash successfully to > start_form_tag, and have ruby put the first value into the first > parameter and the second into the second parameter: > > start_form_tag(({:action => ''create''}), ({:class => ''joe''})) > > I''m sure there''s a more elegant way to do this, but this is what I > could get working for me. Can anybody make this pretty and still have > it work as expected? >The parens around the hashes are superfluous. This ought to work: fun({}, {}) -Scott
Ahhhh... yes it is, thank you. so if I did: fun({}), ({}) that would be a syntax error, as well as fun {}, {} But fun({}, {}) or fun({}) { puts "this is a block" } would be fine. Correct? On 8/16/05, Scott Barron <scott-HDQKq3lYuGDk1uMJSBkQmQ@public.gmane.org> wrote:> > On Aug 16, 2005, at 6:41 PM, Brock Weaver wrote: > > > If you''re using the scaffolding stuff, it has two hash parameters in a > > row. Ruby seems to want to squish those together into the first one: > > > > start_form_tag :action => ''create'', :class => ''joe'' > > > > Sees the first parameter as having two keys, action and class, and the > > second parameter (the "options" one) as having nothing. "&class=joe" > > is then appended to the url since it is part of the first parameter. > > > > Doing: > > > > start_form_tag :action => ''create'', {:class => ''joe''} > > > > Is a syntax error, as ruby sees the {} and assumes a block, not a hash. > > > > Here''s how to explicitly pass an inline hash successfully to > > start_form_tag, and have ruby put the first value into the first > > parameter and the second into the second parameter: > > > > start_form_tag(({:action => ''create''}), ({:class => ''joe''})) > > > > I''m sure there''s a more elegant way to do this, but this is what I > > could get working for me. Can anybody make this pretty and still have > > it work as expected? > > > > The parens around the hashes are superfluous. This ought to work: > > fun({}, {}) > > -Scott > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Brock Weaver http://www.circaware.com
On Aug 16, 2005, at 7:34 PM, Brock Weaver wrote:> Ahhhh... yes it is, thank you. > > so if I did: > > fun({}), ({}) > > that would be a syntax error, as well as > > fun {}, {} > > But > > fun({}, {}) > > or > > fun({}) { puts "this is a block" } > > would be fine. Correct?You''ve got it. -Scott