I'm in a project that uses Symfony 1.2 (I know this is quite old, but I can't do anything about this).
I have a sfWidgetFormPropelChoice widget which feed its options from a foreign key than exists say in table A. I would like to group that foreign key since another column in table A, with the optgroup HTML element.
So I have something like that:
$this->widgetSchema['B_has_A_list'] = new sfWidgetFormPropelChoiceMany(array(
'model' => 'TableA',
));
And I would like to have something that easy:
$this->widgetSchema['B_has_A_list'] = new sfWidgetFormPropelChoiceMany(array(
'model' => 'TableA',
'optgroup' => 'ColumnInTableA', //That's not possible. It would group options grouping by ColumnInTableA using the optgroup HTML element
));
Do you know another easy way to achieve this. Or do you know any extended sfWidgetFormPropelChoice that achieve this?
Thank you.
Ok, I extended the symfony widget to achieve this. If anybody is interesed, it's in github:
https://github.com/laMarciana/sfWidgetFormChoiceOptgroup
To use you have to define the same required options than sfWidgetFormPropelChoice
plus a optgroup_column
option with the PhpName of the column you want to use as the optgroups.
Ex:
$this->widgetSchema['field'] = new sfWidgetFormPropelChoiceOptgroup(array(
'model' => 'Table',
'optgroup_column' => 'Column',
));
I added as well a version for Doctrine.