Symfony2形式的额外选项字段


Extraneous option field in Symfony2 form

我使用的是Symfony 2.5.4版本,我有一个构建器,看起来像这样。

$builder->add('Licensed', 'choice', array(
    'choices' => array(
        'N/A' => '--',
        'Yes' => 'Yes',
        'No' => 'No'
    ),
    'required' => false,
    'label' => 'Somelabel',
    'label_attr' => array('class' => 'font-bold'),
    'attr' => array('class' => 'rounded')
    )
);

当我呈现我得到的表格时:

<select id="companyotherinformation_Licensed" name="companyotherinformation[Licensed]" class="rounded">
        <option value=""></option> <-- Not sure where this is coming from.
        <option value="N/A">--</option>
        <option value="Yes">Yes</option>
        <option value="No">No</option>
</select>

有一个<option value=""></option>,但我不知道它是怎么到那里的。我在哪里可以找到它的来源并将其清除?可能是Symfony2的错误吗?

我也尝试过app/console cache:clear,但仍然无法摆脱它。

不是错误:

http://symfony.com/doc/current/reference/forms/types/choice.html#empty-值

If you leave the empty_value option unset, 
then a blank (with no text) option will automatically be added if and only 
if the required option is false:

因此添加:"empty_value"=>false

但仔细想想,设置required=false意味着用户不必选择任何内容。但有了你的选择,他们别无选择。因此,设置required=true更有意义。