mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
person: create a person with address (php form)
This commit is contained in:
@@ -12,6 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\CreationPersonType;
|
||||
use Chill\PersonBundle\Form\PersonType;
|
||||
@@ -260,6 +262,25 @@ final class PersonController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
$address = $form->get('address')->getData();
|
||||
$addressForm = $form->get('addressForm')->getData();
|
||||
|
||||
if(null !== $address and $addressForm){
|
||||
|
||||
$household = new Household();
|
||||
|
||||
$member = new HouseholdMember();
|
||||
$member->setPerson($person);
|
||||
$member->setStartDate(new \DateTimeImmutable());
|
||||
|
||||
$household->addMember($member);
|
||||
$household->setForceAddress($address);
|
||||
|
||||
$this->em->persist($member);
|
||||
$this->em->persist($household);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute(
|
||||
'chill_person_general_edit',
|
||||
['person_id' => $person->getId()]
|
||||
|
Reference in New Issue
Block a user