From 858cc7f4f230d2d4e1100f7cc4c10446a0b7a2f6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 11 Sep 2013 14:32:57 +0200 Subject: [PATCH] validate customer creation form --- .../Thelia/Config/Resources/routing/front.xml | 6 +- core/lib/Thelia/Controller/BaseController.php | 2 - .../Controller/Front/CustomerController.php | 10 ++- templates/default/register.html | 62 +++++++++++++------ 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index d06585f73..bb1e9422b 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -12,7 +12,7 @@ Thelia\Controller\Front\CustomerController::createAction - connexion + register @@ -57,6 +57,10 @@ + + Thelia\Controller\Front\DefaultController::noAction + cart + Thelia\Controller\Front\CartController::addItem cart diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index bd2556072..988159be4 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -215,8 +215,6 @@ class BaseController extends ContainerAware $url = $this->getRequest()->get("success_url"); } - echo "url=$url"; - if (null !== $url) $this->redirect($url); } diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 85db69472..0a60126e6 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -44,6 +44,7 @@ use Thelia\Core\Security\Exception\WrongPasswordException; */ class CustomerController extends BaseFrontController { + use \Thelia\Cart\CartTrait; /** * Create a new customer. * On success, redirect to success_url if exists, otherwise, display the same view again. @@ -65,7 +66,12 @@ class CustomerController extends BaseFrontController $this->processLogin($customerCreateEvent->getCustomer()); - $this->redirectSuccess($customerCreation); + $cart = $this->getCart($this->getRequest()); + if($cart->getCartItems()->count() > 0) { + $this->redirectToRoute("cart.view"); + } else { + $this->redirectSuccess($customerCreation); + } } catch (FormValidationException $e) { $message = sprintf("Please check your input: %s", $e->getMessage()); } catch (\Exception $e) { @@ -232,7 +238,7 @@ class CustomerController extends BaseFrontController $data["country"], isset($data["email"])?$data["email"]:null, isset($data["password"]) ? $data["password"]:null, - $this->getRequest()->getSession()->getLang(), + $this->getRequest()->getSession()->getLang()->getId(), isset($data["reseller"])?$data["reseller"]:null, isset($data["sponsor"])?$data["sponsor"]:null, isset($data["discount"])?$data["discount"]:null diff --git a/templates/default/register.html b/templates/default/register.html index 48339b873..9e0caf202 100644 --- a/templates/default/register.html +++ b/templates/default/register.html @@ -19,18 +19,44 @@

{intl l="Create New Account"}

{form name="thelia.customer.creation"}
+ {form_field form=$form field='success_url'} + {* the url the user is redirected to on login success *} + {/form_field} + {form_field form=$form field='error_message'} + {* the url the user is redirected to on login success *} + {/form_field} + {form_hidden_fields form=$form} + {if $form_error}
{$form_error_message}
{/if}
1. {intl l="Personal Informations"}
+ {form_field form=$form field="title"} +
+ +
+ + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} {form_field form=$form field="firstname"} -
+
- + {if $error } {$message} {elseif $value != "" && !$error} @@ -40,7 +66,7 @@
{/form_field} {form_field form=$form field="lastname"} -
+
@@ -53,7 +79,7 @@
{/form_field} {form_field form=$form field="email"} -
+
@@ -67,7 +93,7 @@
{/form_field} {form_field form=$form field="phone"} -
+
@@ -80,7 +106,7 @@
{/form_field} {form_field form=$form field="cellphone"} -
+
@@ -102,7 +128,7 @@
{form_field form=$form field="company"} -
+
@@ -116,7 +142,7 @@ {/form_field} {form_field form=$form field="address1"} -
+
@@ -130,7 +156,7 @@ {/form_field} {form_field form=$form field="address2"} -
+
@@ -144,7 +170,7 @@ {/form_field} {form_field form=$form field="city"} -
+
@@ -158,7 +184,7 @@ {/form_field} {form_field form=$form field="zipcode"} -
+
@@ -172,13 +198,13 @@ {/form_field} {form_field form=$form field="country"} -
+
- + {loop type="country" name="country.list"} - + {/loop} {if $error } @@ -198,7 +224,7 @@
{form_field form=$form field="password"} -
+
@@ -212,7 +238,7 @@ {/form_field} {form_field form=$form field="password_confirm"} -
+
@@ -231,7 +257,7 @@