|
|
|
@ -2,25 +2,26 @@
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|
|
|
|
|
|
|
|
|
Class PadController extends AbstractController
|
|
|
|
|
{
|
|
|
|
|
public function showForm(){
|
|
|
|
|
|
|
|
|
|
$form = $this->createFormBuilder()
|
|
|
|
|
private function get_padform(){
|
|
|
|
|
return $this->createFormBuilder()
|
|
|
|
|
->add('content', TextareaType::class)
|
|
|
|
|
->add('save', SubmitType::class, ['label' => 'Enregistrer'])
|
|
|
|
|
->setAction($this->generateUrl('api_post_new'))
|
|
|
|
|
->getForm();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public function showForm(){
|
|
|
|
|
|
|
|
|
|
return $this->render('pad.html.twig', [
|
|
|
|
|
'head_title' => 'Créer un nouveau PAD',
|
|
|
|
|
'page_title' => 'Simple Pad',
|
|
|
|
|
'form' => $form->createView()
|
|
|
|
|
'form' => $this->get_padform()->createView()
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
public function view($id)
|
|
|
|
@ -30,9 +31,20 @@ Class PadController extends AbstractController
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function post()
|
|
|
|
|
public function post(Request $request)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$form = $this->get_padform();
|
|
|
|
|
$form->handleRequest($request);
|
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
|
|
$data = $form->getData();
|
|
|
|
|
return new Response(
|
|
|
|
|
$data["content"]
|
|
|
|
|
);
|
|
|
|
|
//return $this->redirectToRoute('task_success');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|