Commit 1a6575f5 authored by Mat's avatar Mat

postman, retourne 'form invalide'

parent 3f321b9d
......@@ -3,6 +3,7 @@
namespace Api2Bundle\Controller;
use Api2Bundle\Entity\Brasserie;
use Api2Bundle\Form\BrasserieType;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Component\HttpFoundation\Request;
......@@ -31,6 +32,14 @@ class BrasserieController extends FOSRestController
public function putAction(Request $request, Brasserie $id)
{
// le fait de typer $id fait qu'il retourne un objet !
dump($id); die;
$form = $this->createForm(BrasserieType::class, $id);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
dump($form); die;
}
dump('form invalide'); die;
}
}
<?php
namespace Api2Bundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class BrasserieType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('nom')
->add('adresse')
->add('pays');
// pas de submit !
}/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Api2Bundle\Entity\Brasserie'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return '';
// pas de prefix !
}
}
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