Commit bbb94949 authored by Mat's avatar Mat
Browse files

Association, CRud, create and read

parent dbfcf341
......@@ -3,11 +3,40 @@
namespace AssoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use AssoBundle\Entity\Association;
use AssoBundle\Form\Association\AssociationType;
class AssociationController extends Controller
{
/**
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function createAction(Request $request)
{
$association = new Association();
$form = $this->createForm(AssociationType::class, $association);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($association);
$em->flush();
return $this->redirectToRoute('asso_association_read');
}
return $this->render('@Asso/Association/create.html.twig', array(
'formAssociation' => $form->createView()
));
}
/**
*
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function readAction()
......@@ -19,8 +48,8 @@ class AssociationController extends Controller
}
/**
*
*
*/
}
<?php
namespace AssoBundle\Form\Association;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use AssoBundle\Entity\Association;
use AssoBundle\Entity\Membre;
class AssociationType extends AbstractType
{
/**
*
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder->add('nom', TextType::class);
$builder->add('objetSocial', TextareaType::class);
$builder->add('email', TextType::class);
$builder->add('tva', TextType::class);
$builder->add('Enregistrer', SubmitType::class);
}
/**
*
*/
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefault('data_class', Association::class);
}
}
asso_association_read:
path: /
defaults:
defaults:
_controller: AssoBundle:Association:read
asso_association_create:
path: /add
defaults:
_controller: AssoBundle:Association:create
asso_membre_read:
path: /membres
defaults:
defaults:
_controller: AssoBundle:Membre:read
asso_membre_create:
path: /membre/add
defaults:
defaults:
_controller: AssoBundle:Membre:create
{% extends "@Asso/base.html.twig" %}
{% block body %}
<h2>Créer une association</h2>
{{ form(formAssociation) }}
{% endblock %}
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