This commit is contained in:
Gnieark 2020-03-03 19:23:05 +01:00
parent d0a7b38d86
commit 14bc069aec
2 changed files with 11 additions and 6 deletions

View File

@ -15,10 +15,11 @@ use Doctrine\ORM\EntityManagerInterface;
Class PadController extends AbstractController
{
private function get_padform(){
private function get_padform($name = null){
return $this->createFormBuilder()
->add('content', TextareaType::class)
->add('save', SubmitType::class, ['label' => 'Enregistrer'])
->add('name',HiddenType::class,[ 'attr' => ['value' => is_null($name)? '' : $name ]])
->add('crypt_iv', HiddenType::class,[])
->add('crypt_v', HiddenType::class,[])
->add('crypt_iter', HiddenType::class,[])
@ -32,12 +33,12 @@ Class PadController extends AbstractController
->getForm();
}
public function showForm(){
public function showForm($name = null){
return $this->render('pad.html.twig', [
'head_title' => 'Créer un nouveau PAD',
'head_title' => is_null($name) ? 'Créer un nouveau PAD' : 'Créer le pad id ' . $name ,
'page_title' => 'Simple Pad',
'form' => $this->get_padform()->createView()
'form' => $this->get_padform($name)->createView()
]);
}
public function view($name)
@ -49,7 +50,10 @@ Class PadController extends AbstractController
if(count($pads) == 0 )
{
throw new NotFoundHttpException('This pad does not exist');
return $this->showForm($name);
//throw new NotFoundHttpException('This pad does not exist');
}
$pad = $pads[0];
@ -104,7 +108,7 @@ Class PadController extends AbstractController
$entityManager = $this->getDoctrine()->getManager();
$pad = new PAD();
$pad->setContent($data["content"])
->setName( $this-> get_free_name() )
->setName(( $data["name"] == '' )? $this-> get_free_name() : $data["name"] )
->setCryptIv( $data["crypt_iv"] )
->setCryptMode( $data["crypt_mode"] )
->setCryptAdata( is_null( $data["crypt_adata"])? "" : $data["crypt_adata"] )

View File

@ -21,6 +21,7 @@
</em>
</nav>
{{ form_start(form) }}
{{ form_widget(form.name, {}) }}
{{ form_widget(form.crypt_iv, {}) }}
{{ form_widget(form.crypt_v, {}) }}
{{ form_widget(form.crypt_iter, {}) }}