In my entity, I have a field like :
/**
* @var decimal $Size
*
* @ORM\Column(name="Size", type="decimal", scale="2")
* @Assert\NotBlank()
* @Assert\Type(type="numeric")
*/
private $Size;
But when I type a string, like 'foo' in the creation form, the function bindRequest throws :
Expected argument of type "numeric", "boolean" given
500 Internal Server Error - UnexpectedTypeException
The controller code is :
$request = $this->get('request');
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if ($form->isValid())
{
$em = $this->getDoctrine()->getEntityManager();
$em->persist($support);
$em->flush();
return $this->redirect($this->generateUrl('mediatheque_support_' . $shortcut . '_list'));
}
}
Any ideas ?
Tha开发者_如何学编程nks
Are you sure that isn't the expected behavior? You're Asserting a type "numeric" and providing a string "foo"... the error message is a little misleading however saying "boolean" provided
精彩评论