我想一個布爾值傳遞給我的DogForm
訪問通過
$dogForm = new DogForm(null, array("has_cats" => $this->getUser()->hasCats()));
$form = $this->createForm($dogForm, $dog);
在buildForm($選項)一個變量,但在我的DogForm
做時:
if (!isset($options['has_cats'])) {
throw new \Exception("Missing option has_cats, this option is mandatory");
}
它總是給我這個錯誤。
所以我知道狗不應該有貓,但是,我的has_cats
選項去?
謝謝。
謝謝克里斯。如果其他人知道他們是否閱讀過這些內容,則必須在CatForm中的getDefaultOptions()中添加「has_cats」。 – 2012-01-02 15:32:12