add validation to aggregator and filters

This commit is contained in:
2017-03-07 16:03:49 +01:00
parent cc91ade6fe
commit 559239aca1
7 changed files with 55 additions and 6 deletions

View File

@@ -49,11 +49,19 @@ class GenderFilter implements FilterInterface
Person::FEMALE_GENDER => 'Woman',
Person::MALE_GENDER => 'Man'
),
'multiple' => true,
'multiple' => false,
'expanded' => false
));
}
public function validateForm($data, ExecutionContextInterface $context)
{
if (count($data['accepted_genders']) === 0) {
$context->buildViolation("You should select an option")
->addViolation();
}
}
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');