create edit page

This commit is contained in:
Julien Fastré 2013-11-06 19:19:02 +01:00
parent b89c5e3de4
commit d366a76567
4 changed files with 84 additions and 0 deletions

View File

@ -21,6 +21,20 @@ class PersonController extends Controller {
}
public function editAction($id) {
$person = $this->_getPerson($id);
if ($person === null) {
$this->createNotFoundException();
}
$form = $this->createForm(new \CL\Chill\PersonBundle\Form\PersonType(), $person);
return $this->render('CLChillPersonBundle:Person:edit.html.twig',
array('person' => $person,
'form' => $form->createView()));
}
public function searchAction() {
$q = $this->getRequest()->query->getAlnum('q', '');
$q = trim($q);

51
Form/PersonType.php Normal file
View File

@ -0,0 +1,51 @@
<?php
namespace CL\Chill\PersonBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class PersonType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$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')
;
}
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'CL\Chill\PersonBundle\Entity\Person'
));
}
/**
* @return string
*/
public function getName()
{
return 'cl_chill_personbundle_person';
}
}

View File

@ -7,6 +7,11 @@ chill_person_view:
menu: person
order: 50
label: menu.person.general_view
chill_person_general_edit:
pattern: /view/{id}/edit
defaults: {_controller: CLChillPersonBundle:Person:edit }
chill_person_search:

View File

@ -0,0 +1,14 @@
{% extends "CLChillPersonBundle::layout.html.twig" %}
{% set activeRouteKey = '' %}
{% block title %}CLChillPersonBundle:Person:see{% endblock %}
{% block personcontent %}
{% form_theme form 'CLChillMainBundle:Form:fields.html.twig' %}
{{ form(form) }}
{% endblock personcontent %}