谁能告诉我,为什么在形式需要我有一个领域:为什么Symfony2的形式要求fiels
<input type="checkbox" id="client_invoice" name="client[invoice]" class="invoice-controller" value="1" required="required">
如果实体我设置:
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @var boolean
*/
protected $invoice;
我客串是becouse在我有:
$builder->add('invoice', 'checkbox', array('label' => 'form.client.invoice'));
然后'必需的'值被自动设置为true(因为add函数中的第三个参数)。我是对的,还是有另一个理由,这个领域是必需的?
http://symfony.com/doc/current/book/forms.html#field-type-options-guessing – JayKey 2014-12-08 08:47:44
*“这些领域的选择是:您可以将其关闭指定的表单字段只有当你使用Symfony来猜测字段类型时(如**省略或者传递null **作为第二个参数来添加()),才猜到了。“*你正在传递'checkbox'。 (但很好的电话;)) – Yoshi 2014-12-08 08:50:00
这就是我正在寻找的答案,谢谢:) – JayKey 2014-12-08 08:50:57