Add route and view for customer creation

This commit is contained in:
mespeche
2013-09-10 16:35:34 +02:00
parent 615f61bdc4
commit a485456431
4 changed files with 225 additions and 108 deletions

View File

@@ -37,6 +37,11 @@
<default key="_controller">Thelia\Controller\Admin\CustomerController::indexAction</default>
</route>
<route id="admin.customer.update.view" path="/admin/customer/update/{customer_id}">
<default key="_controller">Thelia\Controller\Admin\CustomerController::viewAction</default>
<requirement key="customer_id">\d+</requirement>
</route>
<!-- end Customer rule management -->
<!-- Categories management -->

View File

@@ -37,4 +37,12 @@ class CustomerController extends BaseAdminController
return $this->render("customers", array("display_customer" => 20));
}
public function viewAction($customer_id)
{
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
}
}

View File

@@ -43,19 +43,28 @@ class CustomerCreation extends BaseForm
"constraints" => array(
new Constraints\NotBlank()
),
"label" => "firstname"
"label" => "Firstname",
"label_attr" => array(
"for" => "firstname"
)
))
->add("lastname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => "lastname"
"label" => "Lastname",
"label_attr" => array(
"for" => "lastname"
)
))
->add("address1", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => "address"
"label" => "Address",
"label_attr" => array(
"for" => "address"
)
))
->add("address2", "text", array(
"label" => "Address Line 2"
@@ -64,28 +73,43 @@ class CustomerCreation extends BaseForm
"label" => "Address Line 3"
))
->add("phone", "text", array(
"label" => "phone"
"label" => "Phone",
"label_attr" => array(
"for" => "phone"
)
))
->add("cellphone", "text", array(
"label" => "cellphone"
"label" => "Cellphone",
"label_attr" => array(
"for" => "cellphone"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => "zipcode"
"label" => "Zip code",
"label_attr" => array(
"for" => "zipcode"
)
))
->add("city", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => "city"
"label" => "City",
"label_attr" => array(
"for" => "city"
)
))
->add("country", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => "country"
"label" => "Country",
"label_attr" => array(
"for" => "country"
)
))
->add("title", "text", array(
"constraints" => array(
@@ -104,7 +128,10 @@ class CustomerCreation extends BaseForm
)
))
),
"label" => "email"
"label" => "Email",
"label_attr" => array(
"for" => "email"
)
))
->add("email_confirm", "email", array(
"constraints" => array(
@@ -115,14 +142,20 @@ class CustomerCreation extends BaseForm
)
))
),
"label" => "email confirmation"
"label" => "Email confirmation",
"label_attr" => array(
"for" => "email-confirmation"
)
))
->add("password", "password", array(
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4)))
),
"label" => "password"
"label" => "Password",
"label_attr" => array(
"for" => "password"
)
))
->add("password_confirm", "password", array(
"constraints" => array(
@@ -132,7 +165,10 @@ class CustomerCreation extends BaseForm
array($this, "verifyPasswordField")
)))
),
"label" => "password confirmation"
"label" => "Password confirmation",
"label_attr" => array(
"for" => "password-confirmation"
)
))
;

View File

@@ -136,4 +136,72 @@
</div>
</div>
{* Adding a new Category *}
{form name="thelia.customer.creation"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "customer_creation_dialog"}
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/customer/update/_ID_'}" />
{/form_field}
{form_field form=$form field='firstname'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Firstname'}" placeholder="{intl l='Firstname'}">
</div>
{/form_field}
{form_field form=$form field='lastname'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Lastname'}" placeholder="{intl l='Lastname'}">
</div>
{/form_field}
{form_field form=$form field='address1'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Address'}" placeholder="{intl l='Address'}">
</div>
<div class="form-group">
{form_field form=$form field='address2'}
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Additional address'}" placeholder="{intl l='Additional address'}">
{/form_field}
</div>
<div class="form-group">
{form_field form=$form field='address3'}
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Additional address'}" placeholder="{intl l='Additional address'}">
{/form_field}
</div>
{/form_field}
{/capture}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "add_customer_dialog"
dialog_title = {intl l="Create a new customer"}
dialog_body = {$smarty.capture.customer_creation_dialog nofilter}
dialog_ok_label = {intl l="Create this customer"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {url path='/admin/customer/create'}
form_enctype = {form_enctype form=$form}
form_error_message = $form_error_message
}
{/form}
{/block}