2011-12-14 7 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))); 
関連する問題