mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 06:14:59 +00:00
add validation to aggregator and filters
This commit is contained in:
@@ -112,7 +112,7 @@ class CountPerson implements ExportInterface
|
||||
}
|
||||
|
||||
$labels = array_combine($values, $values);
|
||||
$labels['_header'] = 'Number of people';
|
||||
$labels['_header'] = $this->getTitle();
|
||||
|
||||
return function($value) use ($labels) {
|
||||
return $labels[$value];
|
||||
|
@@ -20,13 +20,14 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||
|
||||
/**
|
||||
* Render a list of peoples
|
||||
*
|
||||
* @author julien
|
||||
*/
|
||||
class ListPerson implements ListInterface
|
||||
class ListPerson implements ListInterface, ExportElementValidatedInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
@@ -126,6 +127,26 @@ class ListPerson implements ListInterface
|
||||
));
|
||||
}
|
||||
|
||||
public function validateForm($data, ExecutionContextInterface $context)
|
||||
{
|
||||
dump($data);
|
||||
// get the field starting with address_
|
||||
$addressFields = array_filter(function($el) {
|
||||
return substr($el, 0, 8) === 'address_';
|
||||
}, $this->fields);
|
||||
dump($data['address_date']);
|
||||
// check if there is one field starting with address in data
|
||||
if (count(array_intersect($data['fields'], $addressFields)) > 0) {
|
||||
// if a field address is checked, the date must not be empty
|
||||
if (empty($data['address_date'])) {
|
||||
$context
|
||||
->buildViolation("You must set this date if an address is checked")
|
||||
->atPath('address_date')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom fields associated with person
|
||||
*
|
||||
|
Reference in New Issue
Block a user