add mobilenumber + validation on email and phonenumber (regex)

This commit is contained in:
nobohan 2018-05-14 12:17:33 +02:00
parent db00a0d265
commit 2f03f925ca
3 changed files with 146 additions and 108 deletions

View File

@ -72,6 +72,9 @@ class Person implements HasCenterInterface {
/** @var string The person's phonenumber */ /** @var string The person's phonenumber */
private $phonenumber = ''; private $phonenumber = '';
/** @var string The person's mobile phone number */
private $mobilenumber = '';
//TO-ADD : caseOpeningDate //TO-ADD : caseOpeningDate
//TO-ADD nativeLanguag //TO-ADD nativeLanguag
@ -603,6 +606,29 @@ class Person implements HasCenterInterface {
return $this->phonenumber; return $this->phonenumber;
} }
/**
* Set mobilenumber
*
* @param string $mobilenumber
* @return Person
*/
public function setMobilenumber($mobilenumber = '')
{
$this->mobilenumber = $mobilenumber;
return $this;
}
/**
* Get mobilenumber
*
* @return string
*/
public function getMobilenumber()
{
return $this->mobilenumber;
}
public function __toString() public function __toString()
{ {
return $this->getLabel(); return $this->getLabel();

View File

@ -27,6 +27,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Chill\PersonBundle\Form\Type\GenderType; use Chill\PersonBundle\Form\Type\GenderType;
use Chill\MainBundle\Form\Type\Select2CountryType; use Chill\MainBundle\Form\Type\Select2CountryType;
@ -80,7 +81,7 @@ class PersonType extends AbstractType
} }
if ($this->config['email'] === 'visible') { if ($this->config['email'] === 'visible') {
$builder->add('email', TextareaType::class, array('required' => false)); $builder->add('email', EmailType::class, array('required' => false));
} }
if ($this->config['country_of_birth'] === 'visible') { if ($this->config['country_of_birth'] === 'visible') {

View File

@ -30,6 +30,17 @@ Chill\PersonBundle\Entity\Person:
accompanyingPeriods: accompanyingPeriods:
- Valid: - Valid:
traverse: true traverse: true
email:
- Email:
groups: [general, creation]
message: 'The email "{{ value }}" is not a valid email.'
phonenumber:
- Regex:
pattern: '/^([\+{1}]|[0])([0-9\s*]{4,20})$/'
groups: [general, creation]
message: 'Invalid phone number: it should begin with "0" or "+", hold only digits and be smaller than 20 characters '
constraints: constraints:
- Callback: - Callback:
callback: isAccompanyingPeriodValid callback: isAccompanyingPeriodValid