2011-12-14 68 views
1

的Symfony 1.4在默認情況下從MySQL枚舉生成列表元素,如:枚舉到選擇列表。更改<option>標記值

<option value="free">free</option> 
<option value="machine">machine</option> 

我應該怎麼做來改變選項標記值?例如:

<option value="free">Different value than free</option> 

回答

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)));