diff --git a/app/locales/en.yml b/app/locales/en.yml index caf64de..cb42d79 100644 --- a/app/locales/en.yml +++ b/app/locales/en.yml @@ -8,13 +8,18 @@ app: title: 'About' form: + error: + not_blank: 'This value should not be blank bro!' title: placeholder: 'Title' cipher: + alert: 'By enabling cipher, fork will be not possible.' + label: 'Cipher: %value%' choice: yes: 'Yes' no: 'No' type: + label: 'Language: %value%' choice: xml: 'HTML/XML' css: 'CSS' diff --git a/src/Gist/Controller/HomeController.php b/src/Gist/Controller/HomeController.php index 638740f..0ec2735 100644 --- a/src/Gist/Controller/HomeController.php +++ b/src/Gist/Controller/HomeController.php @@ -14,9 +14,22 @@ class HomeController { public function indexAction(Request $request, Application $app) { - $form = new CreateGistForm($app['form.factory'], $app['translator']); + $data = array( + 'type' => 'xml', + 'cipher' => 'no', + ); + + $form = new CreateGistForm($app['form.factory'], $app['translator'], $data); $form = $form->build(); + if ($request->isMethod('post')) { + $form->submit($request); + + if ($form->isValid()) { + + } + } + return $app['twig']->render( 'Home/index.html.twig', array( diff --git a/src/Gist/Form/AbstractForm.php b/src/Gist/Form/AbstractForm.php index 220d7d4..cee27f8 100644 --- a/src/Gist/Form/AbstractForm.php +++ b/src/Gist/Form/AbstractForm.php @@ -15,11 +15,11 @@ abstract class AbstractForm protected $translator; - public function __construct(FormFactory $formFactory, Translator $translator) + public function __construct(FormFactory $formFactory, Translator $translator, array $data = array()) { $this->translator = $translator; - $this->builder = $formFactory->createBuilder('form'); + $this->builder = $formFactory->createBuilder('form', $data); } abstract public function build(array $options = array()); diff --git a/src/Gist/Form/CreateGistForm.php b/src/Gist/Form/CreateGistForm.php index f2cd917..a115028 100644 --- a/src/Gist/Form/CreateGistForm.php +++ b/src/Gist/Form/CreateGistForm.php @@ -34,7 +34,9 @@ class CreateGistForm extends AbstractForm 'rows' => 10, ), 'constraints' => array( - new NotBlank(), + new NotBlank(array( + 'message' => $this->translator->trans('form.error.not_blank'), + )), ), ) ); @@ -57,8 +59,8 @@ class CreateGistForm extends AbstractForm array( 'required' => true, 'choices' => array( - 0 => $this->translator->trans('form.cipher.choice.no'), - 1 => $this->translator->trans('form.cipher.choice.yes'), + 'no' => $this->translator->trans('form.cipher.choice.no'), + 'yes' => $this->translator->trans('form.cipher.choice.yes'), ), ) ); diff --git a/src/Gist/Resources/views/Home/index.html.twig b/src/Gist/Resources/views/Home/index.html.twig index 2cc91ca..3c3d739 100644 --- a/src/Gist/Resources/views/Home/index.html.twig +++ b/src/Gist/Resources/views/Home/index.html.twig @@ -1,91 +1,85 @@ {% extends 'base.html.twig' %} {% block body %} -
- - En activant le chiffrement, le code déposé ne pourra pas être forké. -
- -- -
-- -
-