I have a table with items in the following:
id | value
1 | 12
2 | 14
3 | 16
I’m using a sfWidgetFormDoctrineChoice widget which has the following:
$this->widgetSchema['value'] = new sfWidgetFormDoctrineChoice(array(
'model'=>'TemplateFontSize',
'add_empty'=>'Please Select Font Size',
'expanded' => false, 'multiple' => false
));
This outputs the following in HTML
<select>
<option value="1">12</option>
<option value="2">14</option>
<option value="3">12</option>
</select>
Ideally though I’d like the value="" value to to be the value, i.e
<select>
<option value="12">12</option>
<option value="14">14</option>
<option value="16">12</option>
</select>
Is this possible in the widget?
Use
key_methodparam in your widget configuration.See more here.
UPDATE: you’ll also need to do something similar to the validator. By default it expects the PK as the submited value. You need to “tell” it that it should expect another column. Something like (haven’t tested):
More here.