How to add extra value to form?


Ok, I am a total n00b when it comes to this stuff, but am working as a
designer on a project built on ror. Here’s my question.

I want to add js tooltips to pop up when a form field is focused on.
This is easy enough…have the script running, works fine. The problem
is, how do I add the necessary value (tooltiptext) into the form field.

For example, I would like to do something like this: <%= text_field
‘person’, ‘name’, :class => ‘formtext’ , :tooltiptext = > ‘This is the
text’ %>

But obviously ror doesn’t understand tooltiptext…is there some way to
just append an html value (i.e. tooltiptext=x) to the text field call?
Or another workaround?

Thanks in advance.


are you taking about the off-yellow box that the browser shows you
when you mouse over something? or are you talking about a homemade
tooltip solution?

if it’s the first, it is the ‘title’ attribute, so you would want to
do :title => ‘look at me!’ in the html options for the tag. however,
i believe IE will show you the alt attribute, so if you do both :alt
and :title, you should be safe.


No, I am talking about a homemade solution. So title and alt attributes
won’t work.


well then you are going to have to rely on using the element events to
show/hide your tooltips

something like:

<%= text_field …, :onfocus => “show_tooltip(…)”, :onblur =>
“hide_tooltip(…)” %>

i don’t know how you are implementing your tooltips so i can’t really
provide more than that.