При создании формы получаю ошибку. Expected argument of type "string", "AppBundle\Form\BookType" given
500 Internal Server Error - UnexpectedTypeException
public function newAction(Request $request)
{
$book = new Book();
$form = $this->createForm(new BookType(), $book);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($book);
$em->flush();
return $this->redirectToRoute('book_show', array('id' => $book->getId()));
}
return $this->render('book/new.html.twig', array(
'book' => $book,
'form' => $form->createView(),
));
}
class BookType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', 'text')
;
}
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => Book::class,
));
}
/**
* @return string
*/
public function getName()
{
return 'book_form';
}