Symfony forms: how to change default widget for form generation
Posted
by caymcorp
on Stack Overflow
See other posts from Stack Overflow
or by caymcorp
Published on 2010-05-21T10:48:17Z
Indexed on
2010/05/21
10:50 UTC
Read the original article
Hit count: 353
I'm using a custom Widget for date fields, and I want to use it in all my forms. The problem is that symfony uses the default sfWidgetFormDate. What I want is to change this default widget in order to generate forms with my custom Widget. I don't want to change by hand all the forms generated.
The only approach I have found is the treak of modify BaseFormDoctrine.php:
public function setup()
{
foreach($this->getWidgetSchema()->getFields() as $name=>$widget)
{
if($widget instanceof sfWidgetFormDate)
{
$this->widgetSchema[$name] = new sfWidgetFormJQueryDate(array(
'config' => '{}',
'image'=>'/images/calendar.png',
));
}
}
}
© Stack Overflow or respective owner