Commit 21676a20 authored by Marc Ducobu's avatar Marc Ducobu

Displaying & edit marital status

parent 98e1fb66
......@@ -24,9 +24,7 @@ namespace Chill\PersonBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Chill\PersonBundle\Form\Type\CivilType;
use Chill\PersonBundle\Form\Type\GenderType;
use CL\BelgianNationalNumberBundle\Form\BelgianNationalNumberType;
class PersonType extends AbstractType
{
......@@ -57,6 +55,9 @@ class PersonType extends AbstractType
'required' => false,
'multiple' => true
))
->add('maritalStatus', 'select2_chill_marital_status', array(
'required' => false
))
;
if($options['cFGroup']) {
......@@ -65,7 +66,6 @@ class PersonType extends AbstractType
array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup']))
;
}
}
/**
......
<?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,
));
}
}
<?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
));
}
}
......@@ -9,7 +9,7 @@ services:
- "@request"
tags:
- { name: form.type, alias: closing_motive }
chill.person.search_person:
class: Chill\PersonBundle\Search\PersonSearch
arguments:
......@@ -20,21 +20,28 @@ services:
- ['setContainer', ["@service_container"]]
tags:
- { 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:
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodOpening
arguments:
- "@doctrine.orm.entity_manager"
tags:
- { name: chill.timeline, context: 'person' }
chill.person.timeline.accompanying_period_closing:
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodClosing
arguments:
- "@doctrine.orm.entity_manager"
tags:
- { name: chill.timeline, context: 'person' }
chill.person.security.authorization.person:
class: Chill\PersonBundle\Security\Authorization\PersonVoter
arguments:
......
......@@ -44,6 +44,7 @@
<legend><h2>{{ 'Administrative information'|trans }}</h2></legend>
{{ form_row(form.nationality, { 'label' : 'Nationality'|trans} ) }}
{{ form_row(form.spokenLanguages, {'label' : 'Spoken languages'}) }}
{{ form_row(form.maritalStatus, { 'label' : 'Marital status'} ) }}
</fieldset>
<fieldset>
......
......@@ -113,6 +113,12 @@ This view should receive those arguments:
{% endif %}
</dd>
</dl>
<dl>
<dt class="inline">{{'Marital status'|trans}}</dt>
<dd>
{{ person.maritalStatus.name|localize_translatable_string }}
</dd>
</dl>
</figure>
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment