誰能告訴我,爲什麼在形式需要我有一個領域:爲什麼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