edit template & update action

This commit is contained in:
2013-11-07 22:38:11 +01:00
parent d366a76567
commit 574d1d4dcf
10 changed files with 240 additions and 22 deletions

View File

@@ -5,6 +5,9 @@ namespace CL\Chill\PersonBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use CL\Chill\PersonBundle\Form\Type\CivilType;
use CL\Chill\PersonBundle\Form\Type\GenderType;
use CL\BelgianNationalNumberBundle\Form\BelgianNationalNumberType;
class PersonType extends AbstractType
{
@@ -17,17 +20,28 @@ class PersonType extends AbstractType
$builder
->add('name')
->add('surname')
->add('dateOfBirth')
->add('placeOfBirth')
->add('genre')
->add('civil_union')
->add('nbOfChild')
->add('belgian_national_number')
->add('memo')
->add('address')
->add('email')
->add('countryOfBirth')
->add('nationality')
->add('dateOfBirth', 'date', array('required' => false))
->add('placeOfBirth', 'text', array('required' => false))
->add('genre', new GenderType(), array(
'required' => false
))
->add('civil_union', new CivilType(), array(
'required' => false
))
->add('nbOfChild', 'integer', array('required' => false))
->add('belgian_national_number', new BelgianNationalNumberType(),
array('required' => false))
->add('memo', 'text', array('required' => false))
->add('address', 'text', array('required' => false))
->add('email', 'text', array('required' => false))
->add('countryOfBirth', 'entity', array(
'required' => false,
'class' => 'CL\Chill\MainBundle\Entity\Country'
))
->add('nationality', 'entity', array(
'required' => false,
'class' => 'CL\Chill\MainBundle\Entity\Country'
))
;
}

46
Form/Type/CivilType.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
namespace CL\Chill\PersonBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use CL\Chill\PersonBundle\Entity\Person;
/**
* A type to select the civil union state
*
* @author julien
*/
class CivilType extends AbstractType {
public function getName() {
return 'civil';
}
public function getParent() {
return 'choice';
}
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$rootTranslate = 'person.civil_union.';
$a = array(
Person::CIVIL_COHAB => $rootTranslate.Person::CIVIL_COHAB,
Person::CIVIL_DIVORCED => $rootTranslate.Person::CIVIL_DIVORCED,
Person::CIVIL_SEPARATED => $rootTranslate.Person::CIVIL_SEPARATED,
Person::CIVIL_SINGLE => $rootTranslate.Person::CIVIL_SINGLE,
Person::CIVIL_UNKNOW => $rootTranslate.Person::CIVIL_UNKNOW,
Person::CIVIL_WIDOW => $rootTranslate.Person::CIVIL_WIDOW
);
$resolver->setDefaults(array(
'choices' => $a,
'expanded' => false,
'multiple' => false,
));
}
}

42
Form/Type/GenderType.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
namespace CL\Chill\PersonBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use CL\Chill\PersonBundle\Entity\Person;
/**
* A type to select the civil union state
*
* @author julien
*/
class GenderType extends AbstractType {
public function getName() {
return 'gender';
}
public function getParent() {
return 'choice';
}
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$rootTranslate = 'person.gender.';
$a = array(
Person::GENRE_MAN => $rootTranslate.Person::GENRE_MAN,
Person::GENRE_WOMAN => $rootTranslate.Person::GENRE_WOMAN
);
$resolver->setDefaults(array(
'choices' => $a,
'expanded' => true,
'multiple' => false,
'empty_value' => $rootTranslate.'undefined'
));
}
}