Attaching javascript events to form widgets
- by user334017
I have a form with a drop down menu and I want to do a javascript action whenever the user changes the selection. I imagine it is possible find the input later, using javascript, and attach an event to to it; but it seems like it would be easier if there was some sort of attribute or option that could be defined in form-configure(): e.g.
$this->widgetSchema['menu'] = new sfWidgetFormChoice(array(
...
'onclick' => javascript function
));
obviously this doesn't work, and it probably wouldn't be an onclick method either, but my question is how do you attach a javascript event to a input/widget?