mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
fix person validation
This commit is contained in:
parent
400ce3ac82
commit
06cbe8325c
@ -20,7 +20,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use function array_filter;
|
use function array_filter;
|
||||||
use function array_values;
|
use function array_values;
|
||||||
|
|
||||||
|
@ -131,6 +131,8 @@ final class PersonController extends AbstractController
|
|||||||
->getFlashBag()->add('error', $this->translator
|
->getFlashBag()->add('error', $this->translator
|
||||||
->trans('This form contains errors'));
|
->trans('This form contains errors'));
|
||||||
} elseif ($form->isSubmitted() && $form->isValid()) {
|
} elseif ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
$this->em->flush();
|
||||||
|
|
||||||
$this->get('session')->getFlashBag()
|
$this->get('session')->getFlashBag()
|
||||||
->add(
|
->add(
|
||||||
'success',
|
'success',
|
||||||
@ -138,8 +140,6 @@ final class PersonController extends AbstractController
|
|||||||
->trans('The person data has been updated')
|
->trans('The person data has been updated')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->em->flush();
|
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_person_view', [
|
return $this->redirectToRoute('chill_person_view', [
|
||||||
'person_id' => $person->getId(),
|
'person_id' => $person->getId(),
|
||||||
]);
|
]);
|
||||||
|
@ -62,9 +62,7 @@ use function in_array;
|
|||||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
* "person": Person::class
|
* "person": Person::class
|
||||||
* })
|
* })
|
||||||
* @PersonHasCenter(
|
* @PersonHasCenter
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
|
||||||
* @HouseholdMembershipSequential(
|
* @HouseholdMembershipSequential(
|
||||||
* groups={"household_memberships"}
|
* groups={"household_memberships"}
|
||||||
* )
|
* )
|
||||||
@ -250,8 +248,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
*
|
*
|
||||||
* @ORM\Column(type="text", nullable=true)
|
* @ORM\Column(type="text", nullable=true)
|
||||||
* @Assert\Email(
|
* @Assert\Email(
|
||||||
* checkMX=true,
|
* checkMX=true
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
private $email = '';
|
private $email = '';
|
||||||
@ -262,12 +259,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255)
|
* @ORM\Column(type="string", length=255)
|
||||||
* @Assert\NotBlank(
|
* @Assert\NotBlank
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
|
||||||
* @Assert\Length(
|
* @Assert\Length(
|
||||||
* max=255,
|
* max=255,
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
private $firstName;
|
private $firstName;
|
||||||
@ -288,9 +282,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=9, nullable=true)
|
* @ORM\Column(type="string", length=9, nullable=true)
|
||||||
* @Assert\NotNull(
|
* @Assert\NotNull
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
|
||||||
*/
|
*/
|
||||||
private $gender;
|
private $gender;
|
||||||
|
|
||||||
@ -334,12 +326,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255)
|
* @ORM\Column(type="string", length=255)
|
||||||
* @Assert\NotBlank(
|
* @Assert\NotBlank
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
|
||||||
* @Assert\Length(
|
* @Assert\Length(
|
||||||
* max=255,
|
* max=255,
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
private $lastName;
|
private $lastName;
|
||||||
@ -367,9 +356,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* @var DateTime
|
* @var DateTime
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="date", nullable=true)
|
* @ORM\Column(type="date", nullable=true)
|
||||||
* @Assert\Date(
|
* @Assert\Date
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
|
||||||
*/
|
*/
|
||||||
private ?DateTime $maritalStatusDate = null;
|
private ?DateTime $maritalStatusDate = null;
|
||||||
|
|
||||||
@ -388,11 +375,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
* @Assert\Regex(
|
* @Assert\Regex(
|
||||||
* pattern="/^([\+{1}])([0-9\s*]{4,20})$/",
|
* pattern="/^([\+{1}])([0-9\s*]{4,20})$/",
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
* )
|
||||||
* @PhonenumberConstraint(
|
* @PhonenumberConstraint(
|
||||||
* type="mobile",
|
* type="mobile",
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
private string $mobilenumber = '';
|
private string $mobilenumber = '';
|
||||||
@ -430,7 +415,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* )
|
* )
|
||||||
* @Assert\Valid(
|
* @Assert\Valid(
|
||||||
* traverse=true,
|
* traverse=true,
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
private $otherPhoneNumbers;
|
private $otherPhoneNumbers;
|
||||||
@ -449,11 +433,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
* @Assert\Regex(
|
* @Assert\Regex(
|
||||||
* pattern="/^([\+{1}])([0-9\s*]{4,20})$/",
|
* pattern="/^([\+{1}])([0-9\s*]{4,20})$/",
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
* )
|
||||||
* @PhonenumberConstraint(
|
* @PhonenumberConstraint(
|
||||||
* type="landline",
|
* type="landline",
|
||||||
* groups={"general", "creation"}
|
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
private string $phonenumber = '';
|
private string $phonenumber = '';
|
||||||
|
@ -21,6 +21,7 @@ use Chill\MainBundle\Form\Type\Select2CountryType;
|
|||||||
use Chill\MainBundle\Form\Type\Select2LanguageType;
|
use Chill\MainBundle\Form\Type\Select2LanguageType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\PersonPhone;
|
use Chill\PersonBundle\Entity\PersonPhone;
|
||||||
use Chill\PersonBundle\Form\Type\GenderType;
|
use Chill\PersonBundle\Form\Type\GenderType;
|
||||||
use Chill\PersonBundle\Form\Type\PersonAltNameType;
|
use Chill\PersonBundle\Form\Type\PersonAltNameType;
|
||||||
@ -234,8 +235,7 @@ class PersonType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => 'Chill\PersonBundle\Entity\Person',
|
'data_class' => Person::class,
|
||||||
'validation_groups' => ['general', 'creation'],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$resolver->setRequired([
|
$resolver->setRequired([
|
||||||
|
@ -21,8 +21,6 @@ Chill\PersonBundle\Entity\PersonPhone:
|
|||||||
phonenumber:
|
phonenumber:
|
||||||
- Regex:
|
- Regex:
|
||||||
pattern: '/^([\+{1}])([0-9\s*]{4,20})$/'
|
pattern: '/^([\+{1}])([0-9\s*]{4,20})$/'
|
||||||
groups: [ general, creation ]
|
|
||||||
message: 'Invalid phone number: it should begin with the international prefix starting with "+", hold only digits and be smaller than 20 characters. Ex: +33123456789'
|
message: 'Invalid phone number: it should begin with the international prefix starting with "+", hold only digits and be smaller than 20 characters. Ex: +33123456789'
|
||||||
- Chill\MainBundle\Validation\Constraint\PhonenumberConstraint:
|
- Chill\MainBundle\Validation\Constraint\PhonenumberConstraint:
|
||||||
type: any
|
type: any
|
||||||
groups: [ general, creation ]
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user