validate customer creation form
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<!-- Customer routes -->
|
<!-- Customer routes -->
|
||||||
<route id="customer.create.process" path="/customer/create" methods="post">
|
<route id="customer.create.process" path="/customer/create" methods="post">
|
||||||
<default key="_controller">Thelia\Controller\Front\CustomerController::createAction</default>
|
<default key="_controller">Thelia\Controller\Front\CustomerController::createAction</default>
|
||||||
<default key="_view">connexion</default>
|
<default key="_view">register</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="customer.create.view" path="/register">
|
<route id="customer.create.view" path="/register">
|
||||||
@@ -57,6 +57,10 @@
|
|||||||
<!-- end customer address routes -->
|
<!-- end customer address routes -->
|
||||||
|
|
||||||
<!-- cart routes -->
|
<!-- cart routes -->
|
||||||
|
<route id="cart.view" path="/cart">
|
||||||
|
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||||
|
<default key="_view">cart</default>
|
||||||
|
</route>
|
||||||
<route id="cart.add.process" path="/cart/add">
|
<route id="cart.add.process" path="/cart/add">
|
||||||
<default key="_controller">Thelia\Controller\Front\CartController::addItem</default>
|
<default key="_controller">Thelia\Controller\Front\CartController::addItem</default>
|
||||||
<default key="_view">cart</default>
|
<default key="_view">cart</default>
|
||||||
|
|||||||
@@ -215,8 +215,6 @@ class BaseController extends ContainerAware
|
|||||||
$url = $this->getRequest()->get("success_url");
|
$url = $this->getRequest()->get("success_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "url=$url";
|
|
||||||
|
|
||||||
if (null !== $url) $this->redirect($url);
|
if (null !== $url) $this->redirect($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ use Thelia\Core\Security\Exception\WrongPasswordException;
|
|||||||
*/
|
*/
|
||||||
class CustomerController extends BaseFrontController
|
class CustomerController extends BaseFrontController
|
||||||
{
|
{
|
||||||
|
use \Thelia\Cart\CartTrait;
|
||||||
/**
|
/**
|
||||||
* Create a new customer.
|
* Create a new customer.
|
||||||
* On success, redirect to success_url if exists, otherwise, display the same view again.
|
* 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->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) {
|
} catch (FormValidationException $e) {
|
||||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -232,7 +238,7 @@ class CustomerController extends BaseFrontController
|
|||||||
$data["country"],
|
$data["country"],
|
||||||
isset($data["email"])?$data["email"]:null,
|
isset($data["email"])?$data["email"]:null,
|
||||||
isset($data["password"]) ? $data["password"]:null,
|
isset($data["password"]) ? $data["password"]:null,
|
||||||
$this->getRequest()->getSession()->getLang(),
|
$this->getRequest()->getSession()->getLang()->getId(),
|
||||||
isset($data["reseller"])?$data["reseller"]:null,
|
isset($data["reseller"])?$data["reseller"]:null,
|
||||||
isset($data["sponsor"])?$data["sponsor"]:null,
|
isset($data["sponsor"])?$data["sponsor"]:null,
|
||||||
isset($data["discount"])?$data["discount"]:null
|
isset($data["discount"])?$data["discount"]:null
|
||||||
|
|||||||
@@ -19,18 +19,44 @@
|
|||||||
<h1 id="main-label" class="page-header">{intl l="Create New Account"}</h1>
|
<h1 id="main-label" class="page-header">{intl l="Create New Account"}</h1>
|
||||||
{form name="thelia.customer.creation"}
|
{form name="thelia.customer.creation"}
|
||||||
<form id="form-register" class="form-horizontal" action="{url path="/customer/create"}" method="post" role="form">
|
<form id="form-register" class="form-horizontal" action="{url path="/customer/create"}" method="post" role="form">
|
||||||
|
{form_field form=$form field='success_url'}
|
||||||
|
<input type="hidden" name="{$name}" value="{navigate to="return_to"}" /> {* the url the user is redirected to on login success *}
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
|
{form_field form=$form field='error_message'}
|
||||||
|
<input type="hidden" name="{$name}" value="{intl l="missing or invalid data"}" /> {* the url the user is redirected to on login success *}
|
||||||
|
{/form_field}
|
||||||
|
{form_hidden_fields form=$form}
|
||||||
|
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||||
<fieldset id="register-info" class="panel panel">
|
<fieldset id="register-info" class="panel panel">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
1. {intl l="Personal Informations"}
|
1. {intl l="Personal Informations"}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
{form_field form=$form field="title"}
|
||||||
|
<div class="form-group group-title {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
|
<div class="control-input">
|
||||||
|
<select name="{$name}" id="{$label_attr.for}" class="form-control" required autofocus>
|
||||||
|
<option value="">-- {intl l="Select Title"} --</option>
|
||||||
|
{loop type="title" name="country.list"}
|
||||||
|
<option value="{$ID}" {if $value == $ID}selected{/if} >{$LONG}</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
{if $error }
|
||||||
|
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||||
|
{elseif $value != "" && !$error}
|
||||||
|
<span class="help-block"><i class="icon-ok"></i></span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div><!--/.form-group-->
|
||||||
|
{/form_field}
|
||||||
{form_field form=$form field="firstname"}
|
{form_field form=$form field="firstname"}
|
||||||
<div class="form-group group-firstname {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-firstname {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus required>
|
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" required>
|
||||||
{if $error }
|
{if $error }
|
||||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||||
{elseif $value != "" && !$error}
|
{elseif $value != "" && !$error}
|
||||||
@@ -40,7 +66,7 @@
|
|||||||
</div><!--/.form-group-->
|
</div><!--/.form-group-->
|
||||||
{/form_field}
|
{/form_field}
|
||||||
{form_field form=$form field="lastname"}
|
{form_field form=$form field="lastname"}
|
||||||
<div class="form-group group-lastname {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-lastname {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus required>
|
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus required>
|
||||||
@@ -53,7 +79,7 @@
|
|||||||
</div><!--/.form-group-->
|
</div><!--/.form-group-->
|
||||||
{/form_field}
|
{/form_field}
|
||||||
{form_field form=$form field="email"}
|
{form_field form=$form field="email"}
|
||||||
<div class="form-group group-email {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-email {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
|
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
@@ -67,7 +93,7 @@
|
|||||||
</div><!--/.form-group-->
|
</div><!--/.form-group-->
|
||||||
{/form_field}
|
{/form_field}
|
||||||
{form_field form=$form field="phone"}
|
{form_field form=$form field="phone"}
|
||||||
<div class="form-group group-phone {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-phone {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus>
|
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus>
|
||||||
@@ -80,7 +106,7 @@
|
|||||||
</div><!--/.form-group-->
|
</div><!--/.form-group-->
|
||||||
{/form_field}
|
{/form_field}
|
||||||
{form_field form=$form field="cellphone"}
|
{form_field form=$form field="cellphone"}
|
||||||
<div class="form-group group-cellphone {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-cellphone {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus>
|
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus>
|
||||||
@@ -102,7 +128,7 @@
|
|||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{form_field form=$form field="company"}
|
{form_field form=$form field="company"}
|
||||||
<div class="form-group group-company {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-company {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="Thelia" value="{$value}" autofocus>
|
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="Thelia" value="{$value}" autofocus>
|
||||||
@@ -116,7 +142,7 @@
|
|||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field="address1"}
|
{form_field form=$form field="address1"}
|
||||||
<div class="form-group group-address1 {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-address1 {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="{$label}" value="{$value}" autofocus required>
|
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="{$label}" value="{$value}" autofocus required>
|
||||||
@@ -130,7 +156,7 @@
|
|||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field="address2"}
|
{form_field form=$form field="address2"}
|
||||||
<div class="form-group group-address2 {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-address2 {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="" value="{$value}" autofocus>
|
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="" value="{$value}" autofocus>
|
||||||
@@ -144,7 +170,7 @@
|
|||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field="city"}
|
{form_field form=$form field="city"}
|
||||||
<div class="form-group group-city {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-city {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="New York" value="{$value}" autofocus required>
|
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="New York" value="{$value}" autofocus required>
|
||||||
@@ -158,7 +184,7 @@
|
|||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field="zipcode"}
|
{form_field form=$form field="zipcode"}
|
||||||
<div class="form-group group-zip {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-zip {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="H2T 2V6" value="{$value}" autofocus required>
|
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="H2T 2V6" value="{$value}" autofocus required>
|
||||||
@@ -172,13 +198,13 @@
|
|||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field="country"}
|
{form_field form=$form field="country"}
|
||||||
<div class="form-group group-country {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-country {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<select name"{$name}" id="{$label_attr.for}" class="form-control" required>
|
<select name="{$name}" id="{$label_attr.for}" class="form-control" required>
|
||||||
<option value="">-- Select Country --</option>
|
<option value="">-- {intl l="Select Country"} --</option>
|
||||||
{loop type="country" name="country.list"}
|
{loop type="country" name="country.list"}
|
||||||
<option value="{$ID}">{$TITLE}</option>
|
<option value="{$ID}" {if $value == $ID}selected{/if} >{$TITLE}</option>
|
||||||
{/loop}
|
{/loop}
|
||||||
</select>
|
</select>
|
||||||
{if $error }
|
{if $error }
|
||||||
@@ -198,7 +224,7 @@
|
|||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{form_field form=$form field="password"}
|
{form_field form=$form field="password"}
|
||||||
<div class="form-group group-password {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-password {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="password" name="{$name}" id="{$label_attr.for}" class="form-control" required autocomplete="off">
|
<input type="password" name="{$name}" id="{$label_attr.for}" class="form-control" required autocomplete="off">
|
||||||
@@ -212,7 +238,7 @@
|
|||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field="password_confirm"}
|
{form_field form=$form field="password_confirm"}
|
||||||
<div class="form-group group-password_confirm {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
<div class="form-group group-password_confirm {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<input type="password" name="{$name}" id="{$label_attr.for}" class="form-control" required autocomplete="off">
|
<input type="password" name="{$name}" id="{$label_attr.for}" class="form-control" required autocomplete="off">
|
||||||
@@ -231,7 +257,7 @@
|
|||||||
<div class="control-input">
|
<div class="control-input">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label class="control-label" for="agreed">
|
<label class="control-label" for="agreed">
|
||||||
<input type="checkbox" name="agreed" id="agreed" value="1"> I've read and agreed on <a href="#">Terms & Conditions</a>.
|
<input type="checkbox" name="agreed" id="agreed" value="1" required> I've read and agreed on <a href="#">Terms & Conditions</a>.
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user