I want to pass a boolean to my DogForm
$dogForm = new DogForm(null, array("has_cats" => $this->getUser()->hasCats()));
$form = $this->createForm($dogForm, $dog);
But when doing in my DogForm
:
if (!isset($options['has_cats'])) {
throw new \Exception("Missing option has_cats, this option is mandatory");
}
It always give me this error.
So i know that dogs aren't supposed to have cats but, where my has_cats
option went ?
Thanks.
Options should be passed to the createForm()
method, not to your DogForm
constructor:
$form = $this->createForm(new DogForm(), $dog, array('has_cats' => $cats));
Mind, that you have to add "has_cats" to getDefaultOptions()
as well
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With