fix validation when leaving any household

This commit is contained in:
Julien Fastré 2021-06-15 17:15:45 +02:00
parent e95d8fbc7a
commit 68ecff253a

View File

@ -3,6 +3,7 @@
namespace Chill\PersonBundle\Household;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\ConstraintViolationList;
use Doctrine\Common\Collections\Criteria;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Entity\Household\Position;
@ -94,7 +95,12 @@ class MembersEditor
public function validate(): ConstraintViolationListInterface
{
$list = $this->validator->validate($this->getHousehold(), null, [ self::VALIDATION_GROUP ]);
if ($this->hasHousehold()) {
$list = $this->validator
->validate($this->getHousehold(), null, [ self::VALIDATION_GROUP ]);
} else {
$list = new ConstraintViolationList();
}
foreach ($this->membershipsAffected as $m) {
$list->addAll($this->validator->validate($m, null, [ self::VALIDATION_GROUP ]));