Symfony2 form entity error
I have a problem with this entity form type:
$form->add(
'brands',
'entity',
array(
'multiple' => true,
'expanded' => false,
'auto_initialize' => false,
'class' => 'WebBundle:Brand',
'query_builder' => function (EntityRepository $repository) {
$qb = $repository->createQueryBuilder('b');
return $qb->orderBy('b.name');
}
When I enter into this form, it show correctly. When I submit the form
without selected data (for validation test) symfony2 shows this error.
An exception occurred while executing 'SELECT b0_.id AS id0, b0_.name AS
name1, b0_.slug AS slug2, b0_.emailAccount_id AS emailAccount_id3 FROM
Brand b0_ WHERE b0_.id IN (?) ORDER BY b0_.name ASC' with params [[]]:
Warning: array_fill(): Number of elements must be positive in
/srv/www/dapdabuilder/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php
line 140
If I change the form entity type to expanded: true or I delete
query_builder, this error doesn't show. Also in the query appears a where
statement when I not write it..
I know that a solution this problem is validating the form with html5 or
others manners, but I want to know why this error happens.
No comments:
Post a Comment