From 20943a674cd52d9414b2ef8573b2d1748be7ea8e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 4 Mar 2014 09:37:08 +0100 Subject: [PATCH 23/24] change default success_url for login form in layout file --- templates/frontOffice/default/layout.tpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/frontOffice/default/layout.tpl b/templates/frontOffice/default/layout.tpl index 0b2d721f0..a53d7ea2e 100644 --- a/templates/frontOffice/default/layout.tpl +++ b/templates/frontOffice/default/layout.tpl @@ -104,6 +104,9 @@ GNU General Public License : http://www.gnu.org/licenses/ {form name="thelia.front.customer.login"}
{form_hidden_fields form=$form} + {form_field form=$form field="success_url"} + + {/form_field} {form_field form=$form field="email"}
From d05e28dc43f4a4daac72de19d93f611a72e0a961 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 4 Mar 2014 10:06:47 +0100 Subject: [PATCH 24/24] verify if coupon code is existing --- core/lib/Thelia/Form/CouponCode.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/lib/Thelia/Form/CouponCode.php b/core/lib/Thelia/Form/CouponCode.php index d9b546f1f..1319c1fb8 100644 --- a/core/lib/Thelia/Form/CouponCode.php +++ b/core/lib/Thelia/Form/CouponCode.php @@ -23,6 +23,9 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Core\Translation\Translator; +use Thelia\Model\CouponQuery; /** * Class CouponCode @@ -44,11 +47,25 @@ class CouponCode extends BaseForm "required" => true, "constraints" => array( new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, + "verifyExistingCode") + ) + )) ) ) ); } + public function verifyExistingCode($value, ExecutionContextInterface $context) + { + $coupon = CouponQuery::create()->findOneByCode($value); + if (null === $coupon) { + $context->addViolation(Translator::getInstance()->trans("This coupon does not exists")); + } + } + /** * Form name *