You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
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
|
|
{
|
|
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' => $this->get_padform()->createView()
|
|
]);
|
|
}
|
|
public function view($id)
|
|
{
|
|
return new Response(
|
|
'<h1>plop</h1>'
|
|
);
|
|
}
|
|
|
|
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');
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} |