mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
Displaying & edit marital status
This commit is contained in:
parent
98e1fb663b
commit
21676a20b2
@ -24,9 +24,7 @@ namespace Chill\PersonBundle\Form;
|
|||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||||
use Chill\PersonBundle\Form\Type\CivilType;
|
|
||||||
use Chill\PersonBundle\Form\Type\GenderType;
|
use Chill\PersonBundle\Form\Type\GenderType;
|
||||||
use CL\BelgianNationalNumberBundle\Form\BelgianNationalNumberType;
|
|
||||||
|
|
||||||
class PersonType extends AbstractType
|
class PersonType extends AbstractType
|
||||||
{
|
{
|
||||||
@ -57,6 +55,9 @@ class PersonType extends AbstractType
|
|||||||
'required' => false,
|
'required' => false,
|
||||||
'multiple' => true
|
'multiple' => true
|
||||||
))
|
))
|
||||||
|
->add('maritalStatus', 'select2_chill_marital_status', array(
|
||||||
|
'required' => false
|
||||||
|
))
|
||||||
;
|
;
|
||||||
|
|
||||||
if($options['cFGroup']) {
|
if($options['cFGroup']) {
|
||||||
@ -65,7 +66,6 @@ class PersonType extends AbstractType
|
|||||||
array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup']))
|
array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup']))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Form\Type;
|
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
|
||||||
use 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,
|
|
||||||
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
80
Form/Type/Select2MaritalStatusType.php
Normal file
80
Form/Type/Select2MaritalStatusType.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||||
|
use Chill\MainBundle\Form\Type\DataTransformer\ObjectToIdTransformer;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A type to select the marital status
|
||||||
|
*
|
||||||
|
* @author Champs-Libres COOP
|
||||||
|
*/
|
||||||
|
class Select2MaritalStatusType extends AbstractType
|
||||||
|
{
|
||||||
|
/** @var RequestStack */
|
||||||
|
private $requestStack;
|
||||||
|
|
||||||
|
/** @var ObjectManager */
|
||||||
|
private $em;
|
||||||
|
|
||||||
|
public function __construct(RequestStack $requestStack,ObjectManager $em)
|
||||||
|
{
|
||||||
|
$this->requestStack = $requestStack;
|
||||||
|
$this->em = $em;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName() {
|
||||||
|
return 'select2_chill_marital_status';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getParent() {
|
||||||
|
return 'select2_choice';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$transformer = new ObjectToIdTransformer($this->em,'Chill\PersonBundle\Entity\MaritalStatus');
|
||||||
|
$builder->addModelTransformer($transformer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||||
|
{
|
||||||
|
$locale = $this->requestStack->getCurrentRequest()->getLocale();
|
||||||
|
$maritalStatuses = $this->em->getRepository('Chill\PersonBundle\Entity\MaritalStatus')->findAll();
|
||||||
|
$choices = array();
|
||||||
|
|
||||||
|
foreach ($maritalStatuses as $ms) {
|
||||||
|
$choices[$ms->getId()] = $ms->getName()[$locale];
|
||||||
|
}
|
||||||
|
|
||||||
|
asort($choices, SORT_STRING | SORT_FLAG_CASE);
|
||||||
|
|
||||||
|
$resolver->setDefaults(array(
|
||||||
|
'class' => 'Chill\PersonBundle\Entity\MaritalStatus',
|
||||||
|
'choices' => $choices
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,13 @@ services:
|
|||||||
- ['setContainer', ["@service_container"]]
|
- ['setContainer', ["@service_container"]]
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.search, alias: 'person_regular' }
|
- { name: chill.search, alias: 'person_regular' }
|
||||||
|
chill.main.form.type.select2maritalstatus:
|
||||||
|
class: Chill\PersonBundle\Form\Type\Select2MaritalStatusType
|
||||||
|
arguments:
|
||||||
|
- "@request_stack"
|
||||||
|
- "@doctrine.orm.entity_manager"
|
||||||
|
tags:
|
||||||
|
- { name: form.type, alias: select2_chill_marital_status }
|
||||||
|
|
||||||
chill.person.timeline.accompanying_period_opening:
|
chill.person.timeline.accompanying_period_opening:
|
||||||
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodOpening
|
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodOpening
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
<legend><h2>{{ 'Administrative information'|trans }}</h2></legend>
|
<legend><h2>{{ 'Administrative information'|trans }}</h2></legend>
|
||||||
{{ form_row(form.nationality, { 'label' : 'Nationality'|trans} ) }}
|
{{ form_row(form.nationality, { 'label' : 'Nationality'|trans} ) }}
|
||||||
{{ form_row(form.spokenLanguages, {'label' : 'Spoken languages'}) }}
|
{{ form_row(form.spokenLanguages, {'label' : 'Spoken languages'}) }}
|
||||||
|
{{ form_row(form.maritalStatus, { 'label' : 'Marital status'} ) }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
@ -113,6 +113,12 @@ This view should receive those arguments:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
<dl>
|
||||||
|
<dt class="inline">{{'Marital status'|trans}}</dt>
|
||||||
|
<dd>
|
||||||
|
{{ person.maritalStatus.name|localize_translatable_string }}
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
|
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user