Question on HTML Options {}

I’m looking at some of these form helpers in the API and see where you
put html options in, however I don’t see any examples. I know this is
probably a lame question but can anyone point me to some examples.
How the options are written out perhaps ?

TIA
Stuart

HTML options are just as it sounds, the options put on the request
string.

So url_for :controller => ‘cont’, :action => ‘action’, :id => 1,
:my_option
=> ‘option’ will give you (depending on routes, of course):

‘/cont/action?id=1&my_option=option’

In short, any key,value pair given after the keys expected by options{}
gets
turned into URL string options.

If that doesn’t answer your question, could you post an example of where
you’re confused? Thanks.

Jason

I’m going to asume you’re new to Ruby, please ignore if you aren’t.

As Jason pointed out, it’s just a hash like any other… but make sure
you
don’t fall into this trap:

link_to “Here”, :controller => ‘foo’, :action => ‘bar’, :class =>
‘some_class’

Here ‘class’ is the HTML attribute you’re wanting to assign to the A
tag.
That attribute will never see the light of day however. Ruby has some
great
time saving shortcuts, but if you don’t know they’re there they can also
cause you problems.
Ruby assumes all the arguments after “Here” are all one hash, you need
to
let Ruby that isn’t case so that it’ll take notice of your class
attribute:

link_to “Here”, { :controller => ‘foo’, :action => ‘bar’ }, { :class =>
‘some_class’ }

So when you see that an argument accepts HTML options, just remember the
defined your hash boundaries.

Hope that helps.
Ian

Actually, the link_to, button_to, and url_for I understood. I was
looking at “selects” and didn’t understand the HTML options part.
Perhaps I’m just confusing myself needlessly and they work the same.

Stuart

On Aug 28, 2006, at 2:54 PM, Dark A. wrote:

Actually, the link_to, button_to, and url_for I understood. I was
looking at “selects” and didn’t understand the HTML options part.
Perhaps I’m just confusing myself needlessly and they work the same.

I think that’s a lack of adherence to naming conventions. (Or a lack
of naming conventions?)

It seems that the ‘options’ parameter to the check_box helper method
does what the ‘html_options’ parameter to the select helper method
does (and the select helper method has its own ‘options’ parameter).

Am I misreading it?