mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
create edit page
This commit is contained in:
parent
b89c5e3de4
commit
d366a76567
@ -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
51
Form/PersonType.php
Normal 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';
|
||||
}
|
||||
}
|
@ -8,6 +8,11 @@ chill_person_view:
|
||||
order: 50
|
||||
label: menu.person.general_view
|
||||
|
||||
chill_person_general_edit:
|
||||
pattern: /view/{id}/edit
|
||||
defaults: {_controller: CLChillPersonBundle:Person:edit }
|
||||
|
||||
|
||||
|
||||
chill_person_search:
|
||||
pattern: /search
|
||||
|
14
Resources/views/Person/edit.html.twig
Normal file
14
Resources/views/Person/edit.html.twig
Normal 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 %}
|
Loading…
x
Reference in New Issue
Block a user