在 sfWidgetFormPropelChoice 中使用 optgroup 因为列的值
我正在一个使用 Symfony 1.2 的项目中(我知道这已经很旧了,但我对此无能为力)。
我有一个 sfWidgetFormPropelChoice 小部件,它从表 A 中存在的外键提供选项。我想使用 optgroup HTML 元素将该外键从表 A 中的另一列分组。
所以我有这样的事情:
$this->widgetSchema['B_has_A_list'] = new sfWidgetFormPropelChoiceMany(array(
'model' => 'TableA',
));
我想要那么简单的事情:
$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
));
你知道另一种简单的方法来实现这一点吗?或者您知道任何扩展的 sfWidgetFormPropelChoice 可以实现此目的吗?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我扩展了 symfony 小部件来实现这一点。如果有人有兴趣,请在 github 中:
https://github.com/laMarciana/sfWidgetFormChoiceOptgroup
使用您必须定义与
sfWidgetFormPropelChoice
相同的必需选项以及optgroup_column
选项要用作 optgroup 的列的 PhpName。例如:
我还添加了 Doctrine 的版本。
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 aoptgroup_column
option with the PhpName of the column you want to use as the optgroups.Ex:
I added as well a version for Doctrine.