From 762b5bc71c3aded1bc7ad0f74f26f618fb06f477 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 1 Jul 2013 11:54:40 +0200 Subject: [PATCH] name all form field --- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Thelia/Core/Template/Smarty/Plugins/Form.php | 6 ++++-- core/lib/Thelia/Form/AdminLogin.php | 5 +++++ core/lib/Thelia/Form/BaseForm.php | 2 +- templates/smarty-sample/index.html | 15 +++++++++++++++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index d1e6569fa..4eb0217ae 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -23,6 +23,7 @@
+ diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index f7ee96d2a..2ff6be8e3 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -90,8 +90,10 @@ class Form implements SmartyPluginInterface $instance = $this->getInstance($params['name']); $form = $instance->getForm(); - if (true === $this->request->getSession()->get("form_error", false) && $this->request->getSession()->get - ("form_name") == $instance->getName()) { + if ( + true === $this->request->getSession()->get("form_error", false) && + $this->request->getSession()->get("form_name") == $instance->getName()) + { $form->bind($this->request); $this->request->getSession()->set("form_error", false); } diff --git a/core/lib/Thelia/Form/AdminLogin.php b/core/lib/Thelia/Form/AdminLogin.php index 2fa2c8d5f..33810f771 100644 --- a/core/lib/Thelia/Form/AdminLogin.php +++ b/core/lib/Thelia/Form/AdminLogin.php @@ -41,4 +41,9 @@ class AdminLogin extends BaseForm { ->add("password", "password"); } + public function getName() + { + return "admin_login"; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 3c76df1b5..3a6d69cb3 100644 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -61,7 +61,7 @@ abstract class BaseForm { ) ->addExtension(new ValidatorExtension($validator)) ->getFormFactory() - ->createBuilder($type, $data, $options); + ->createNamedBuilder($this->getName(), $type, $data, $options); ; diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 25814172e..28f78f06c 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -27,6 +27,21 @@ An image from asset directory :
{/form} + +
+ +{form name="thelia.admin_login"} +
+ {form_field_hidden form=$form} + {form_field form=$form.username} + username : + {/form_field} + + {form_field form=$form.password} + password : + {/form_field} +
+{/form}
jQuery data: