默认情况下,Symfony 1.4会生成MySQL枚举的列表元素,如:
<option value="free">free</option>
<option value="machine">machine</option>
如何更改选项标记值?,例如:
<option value="free">Different value than free</option>
答案 0 :(得分:0)
您可以使用以下代码:
$choices = $this->getWidget('mywidget')->getChoices();
// supposing we know what needs to change...
$choices[1] = "new value";
// supposing we don't need other options/attributes
$this->setWidget('mywidget', new sfWidgetFormChoice(array('choices' => $choices)));