如何在symfony2选择框(组合框)中选择数据库值
我的html comobox在这里。
<select name="dashboard_mediabundle_gallerytype[category_id]" id="dashboard_mediabundle_gallerytype_category_id">
<option value="0">Choose an option</option>
<option value="1">india</option>
<option value="2">usa</option>
</select>
和buildform here
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('category_id', 'entity', array(
'class' => 'DashboardMediaBundle:category',
'property' => 'title',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('mc');
},
'label' => 'Category*:',
'by_reference' => false,
'required' => false,
'empty_value' => 'Choose an option',
'data' => 2
));
}
如何设置选定的"<option value="2">usa</option>"
此值?
我尝试“'data'=&gt; 2”但不选择"<option value="2">usa</option>"