I have created a FormType
class called BookType
. The method for generating the form is:
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', 'text', array('required'=>$this->searchForm))
->add('author', 'text', array('required'=>$this->searchForm))
->add('genre', 'text', array('required'=>$this->searchForm));
if(!$this->searchForm) {
$builder
->add('picture', 'text', array('required' => false));
}
$builder
->add('description', 'text', array('required'=>$this->searchForm))
->add('submit', 'submit', array('required'=>$this->searchForm))
;
}
However, whenever I try to access this with the following code:
$book = new Book();
$form = $this->createForm(
new BookType(true),
$book,
[
'action'=> $request->getUri()
]
);
I am seeing the following error message:
The option "required" does not exist. Known options are: "attr", "auto_initialize", "block_name", "disabled", "label", "translation_domain", "validation_groups".
As far as I am aware from the various tutorials I have read, this should be a completely valid parameter. Am I wrong here?
I think error is occurring here:
->add('submit', 'submit', array('required'=>$this->searchForm));
Since 'submit'
field does not have 'required'
option.