you should extend your form class (which should already derivate from sfForm) to override the render
method.
As of symfony 1.4 the sfForm class has no renderJavascript method. We generally use for all our form and widgets a basse class that will define this method and override render method
class abstractOurForm extends sfFormDoctrine
{
public function render($attributes = array())
{
return parent::render($attributes).
'<script type="text/javascript">'.$this->renderJavascript().'</script>';
}
public function renderJavascript()
{
//nothing here
}
}
This will add a javascript tag at the end of your form (if displayed like generated ones with echo $form
)
When you override the doctrine form to implement javascript functionnality tight to the form html (inline validation, ajax integration, dynamic controls, etc.) just do something like this :
class myWhateverForm extends abstractOurForm
{
public function configure()
{
//your widget & validators config here
}
public function renderJavascript()
{
//here come the JS code
$js = <<<EOT
//example with jquery
$(function() {
$('#myElement').focus(function(){
if (window.console) console.log('you\'ve done it');
});
});
EOT;
return $js;
}
}
The same pattern is applied to our widget so if some javascript code is widget specific it does not have to be repeated on each form class using it.
Hope this will help you !