Cleanup :

- I made the form id different between the front and the back office
- I renamed a few files to use the same convention (create / update)
This commit is contained in:
touffies
2013-10-22 09:44:45 +02:00
parent b64dedefc6
commit 0c1ed8e702
19 changed files with 489 additions and 582 deletions

View File

@@ -52,18 +52,27 @@
</loops>
<forms>
<!-- Forms for Frontend -->
<form name="thelia.front.customer.login" class="Thelia\Form\CustomerLogin"/>
<form name="thelia.front.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
<form name="thelia.front.customer.create" class="Thelia\Form\CustomerCreateForm"/>
<form name="thelia.front.customer.profil.update" class="Thelia\Form\CustomerProfilUpdateForm"/>
<form name="thelia.front.customer.password.update" class="Thelia\Form\CustomerPasswordUpdateForm"/>
<form name="thelia.front.address.create" class="Thelia\Form\AddressCreateForm"/>
<form name="thelia.front.address.update" class="Thelia\Form\AddressUpdateForm"/>
<form name="thelia.front.contact" class="Thelia\Form\ContactForm"/>
<!-- Forms for Admin -->
<form name="thelia.install.step3" class="Thelia\Form\InstallStep3Form"/>
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
<form name="thelia.customer.update" class="Thelia\Form\CustomerUpdateForm"/>
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
<form name="thelia.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
<form name="thelia.customer.login" class="Thelia\Form\CustomerLogin"/>
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>
<form name="thelia.address.create" class="Thelia\Form\AddressCreateForm" />
<form name="thelia.address.update" class="Thelia\Form\AddressUpdateForm" />
<form name="thelia.admin.customer.create" class="Thelia\Form\CustomerCreateForm"/>
<form name="thelia.admin.customer.update" class="Thelia\Form\CustomerUpdateForm"/>
<form name="thelia.admin.address.create" class="Thelia\Form\AddressCreateForm" />
<form name="thelia.admin.address.update" class="Thelia\Form\AddressUpdateForm" />
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
<form name="thelia.admin.category.modification" class="Thelia\Form\CategoryModificationForm"/>

View File

@@ -22,6 +22,8 @@
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
@@ -57,115 +59,122 @@ class AddressCreateForm extends BaseForm
{
$this->formBuilder
->add("label", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Address label"),
"label_attr" => array(
"for" => "label_create"
),
"required" => true
))
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Address label"),
"label_attr" => array(
"for" => "address_label"
)
))
->add("title", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title_create"
)
))
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title"
)
))
->add("firstname", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Firstname"),
"label_attr" => array(
"for" => "firstname_create"
)
))
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("First Name"),
"label_attr" => array(
"for" => "firstname"
)
))
->add("lastname", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Lastname"),
"label_attr" => array(
"for" => "lastname_create"
)
))
->add("address1", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Street Address"),
"label_attr" => array(
"for" => "address1_create"
)
))
->add("address2", "text", array(
"label" => Translator::getInstance()->trans("Additional address"),
"label_attr" => array(
"for" => "address2_create"
)
))
->add("address3", "text", array(
"label" => Translator::getInstance()->trans("Additional address"),
"label_attr" => array(
"for" => "address3_create"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode_create"
)
))
->add("city", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city_create"
)
))
->add("country", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country_create"
)
))
->add("phone", "text", array(
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone_create"
)
))
->add("cellphone", "text", array(
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone_create"
)
))
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Last Name"),
"label_attr" => array(
"for" => "lastname"
)
))
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Company"),
"label_attr" => array(
"for" => "company_create"
)
))
->add("is_default", "integer", array(
"label" => Translator::getInstance()->trans("Make this address has my primary address"),
"label_attr" => array(
"for" => "default_address"
)
))
;
"label" => Translator::getInstance()->trans("Company Name"),
"label_attr" => array(
"for" => "company"
),
"required" => false
))
->add("address1", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Street Address"),
"label_attr" => array(
"for" => "address1"
)
))
->add("address2", "text", array(
"label" => Translator::getInstance()->trans("Address Line 2"),
"label_attr" => array(
"for" => "address2"
),
"required" => false
))
->add("address3", "text", array(
"label" => Translator::getInstance()->trans("Address Line 3"),
"label_attr" => array(
"for" => "address3"
),
"required" => false
))
->add("city", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode"
)
))
->add("country", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country"
)
))
// Phone
->add("phone", "text", array(
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone"
),
"required" => false
))
->add("cellphone", "text", array(
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone"
),
"required" => false
))
// Default address
->add("is_default", "checkbox", array(
"label" => Translator::getInstance()->trans("Make this address has my primary address"),
"label_attr" => array(
"for" => "default_address"
),
"required" => false
))
;
}
/**

View File

@@ -22,8 +22,6 @@
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
/**
* Class AddressUpdateForm
@@ -32,136 +30,11 @@ use Thelia\Core\Translation\Translator;
*/
class AddressUpdateForm extends AddressCreateForm
{
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->formBuilder attribute :
*
* $this->formBuilder->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"
* ),
* "label" => "email",
* "constraints" => array(
* new \Symfony\Component\Validator\Constraints\NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
*/
protected function buildForm()
{
parent::buildForm();
$this->formBuilder
->add("label", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Address label *"),
"label_attr" => array(
"for" => "label_update"
),
"required" => true
))
->add("title", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title_update"
)
))
->add("firstname", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Firstname"),
"label_attr" => array(
"for" => "firstname_update"
)
))
->add("lastname", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Lastname"),
"label_attr" => array(
"for" => "lastname_update"
)
))
->add("address1", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Street Address"),
"label_attr" => array(
"for" => "address1_update"
)
))
->add("address2", "text", array(
"label" => Translator::getInstance()->trans("Additional address"),
"label_attr" => array(
"for" => "address2_update"
)
))
->add("address3", "text", array(
"label" => Translator::getInstance()->trans("Additional address"),
"label_attr" => array(
"for" => "address3_update"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode_update"
)
))
->add("city", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city_update"
)
))
->add("country", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country_update"
)
))
->add("phone", "text", array(
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone_update"
)
))
->add("cellphone", "text", array(
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone_update"
)
))
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Compagny"),
"label_attr" => array(
"for" => "company_update"
)
))
;
}
/**

View File

@@ -23,51 +23,32 @@
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Model\ConfigQuery;
use Thelia\Model\CustomerQuery;
use Thelia\Core\Translation\Translator;
/**
* Class CustomerCreation
* Class CustomerCreateForm
* @package Thelia\Form
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CustomerCreation extends BaseForm
class CustomerCreateForm extends AddressCreateForm
{
protected function buildForm()
{
parent::buildForm();
$this->formBuilder
// Remove From Address create form
->remove("label")
->remove("is_default")
// Add
->add("auto_login", "integer")
// Personal Informations
->add("title", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title"
)
))
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("First Name"),
"label_attr" => array(
"for" => "firstname"
)
))
->add("lastname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Last Name"),
"label_attr" => array(
"for" => "lastname"
)
))
// Add Email address
->add("email", "email", array(
"constraints" => array(
new Constraints\NotBlank(),
@@ -84,90 +65,7 @@ class CustomerCreation extends BaseForm
"for" => "email"
)
))
/* ->add("email_confirm", "email", array(
"constraints" => array(
new Constraints\Callback(array(
"methods" => array(
array($this,
"verifyEmailField")
)
))
),
"label" => "email confirmation"
))*/
->add("phone", "text", array(
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone"
),
"required" => false
))
->add("cellphone", "text", array(
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone"
),
"required" => false
))
// Delivery Informations
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Company Name"),
"label_attr" => array(
"for" => "company"
),
"required" => false
))
->add("address1", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Street Address"),
"label_attr" => array(
"for" => "address1"
)
))
->add("address2", "text", array(
"label" => Translator::getInstance()->trans("Address Line 2"),
"label_attr" => array(
"for" => "address2"
),
"required" => false
))
->add("address3", "text", array(
"label" => Translator::getInstance()->trans("Address Line 3"),
"label_attr" => array(
"for" => "address3"
),
"required" => false
))
->add("city", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode"
)
))
->add("country", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country"
)
))
// Login Information
// Add Login Information
->add("password", "password", array(
"constraints" => array(
new Constraints\NotBlank(),
@@ -191,6 +89,7 @@ class CustomerCreation extends BaseForm
"for" => "password_confirmation"
)
))
// Add terms & conditions
->add("agreed", "checkbox", array(
"constraints" => array(
new Constraints\True(array("message" => "Please accept the Terms and conditions in order to register."))
@@ -206,16 +105,7 @@ class CustomerCreation extends BaseForm
$data = $context->getRoot()->getData();
if ($data["password"] != $data["password_confirm"]) {
$context->addViolation("password confirmation is not the same as password field");
}
}
public function verifyEmailField($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if ($data["email"] != $data["email_confirm"]) {
$context->addViolation("email confirmation is not the same as email field");
$context->addViolation("password confirmation is not the same as password field.");
}
}
@@ -223,12 +113,12 @@ class CustomerCreation extends BaseForm
{
$customer = CustomerQuery::create()->findOneByEmail($value);
if ($customer) {
$context->addViolation("This email already exists");
$context->addViolation("This email already exists.");
}
}
public function getName()
{
return "thelia_customer_creation";
return "thelia_customer_create";
}
}

View File

@@ -22,6 +22,8 @@
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Email;
@@ -56,13 +58,13 @@ class CustomerLogin extends BaseForm
)
))
->add("account", "choice", array(
"constraints" => array(
/*"constraints" => array(
new Constraints\Callback(array(
"methods" => array(
array($this, "verifyAccount")
)
))
),
),*/
"choices" => array(
0 => Translator::getInstance()->trans("No, I am a new customer."),
1 => Translator::getInstance()->trans("Yes, I have a password :")
@@ -70,12 +72,21 @@ class CustomerLogin extends BaseForm
"label_attr" => array(
"for" => "account"
),
"data" => 0
"data" => 0,
'validation_groups' => function(FormInterface $form) {
$account = $form->getData();
if ($account === 1)
return 'existing_customer';
else
return 'Default';
}
))
->add("password", "password", array(
/*"constraints" => array(
new Constraints\NotBlank()
),*/
"constraints" => array(
new Constraints\NotBlank(array(
'groups' => array('existing_customer'),
))
),
"label" => Translator::getInstance()->trans("Please enter your password"),
"label_attr" => array(
"for" => "password"
@@ -120,6 +131,26 @@ class CustomerLogin extends BaseForm
}
}
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
//'cascade_validation' => true,
// 'csrf_protection' => true,
//'csrf_field_name' => '_token',
'validation_groups' => function(FormInterface $form) {
$data = $form->getData();
if ($data->getAccount() == 1)
return array('Default', 'existing_customer');
else
return 'Default';
}
));
}
public function getName()
{
return "thelia_customer_login";

View File

@@ -1,164 +0,0 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Thelia\Core\Translation\Translator;
/**
* Class CustomerModification
* @package Thelia\Form
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CustomerModification extends BaseForm
{
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->form attribute :
*
* $this->form->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"
* ),
* "label" => "email",
* "constraints" => array(
* new NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
*/
protected function buildForm()
{
$this->formBuilder
->add('update_logged_in_user', 'integer') // In a front office context, update the in-memory logged-in user data
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Company"),
"label_attr" => array(
"for" => "company"
)
))
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("First Name"),
"label_attr" => array(
"for" => "firstname"
)
))
->add("lastname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Last Name"),
"label_attr" => array(
"for" => "lastname"
)
))
->add("address1", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label_attr" => array(
"for" => "address"
),
"label" => Translator::getInstance()->trans("Street Address")
))
->add("address2", "text", array(
"label" => Translator::getInstance()->trans("Address Line 2"),
"label_attr" => array(
"for" => "address2"
)
))
->add("address3", "text", array(
"label" => Translator::getInstance()->trans("Address Line 3"),
"label_attr" => array(
"for" => "address3"
)
))
->add("phone", "text", array(
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone"
)
))
->add("cellphone", "text", array(
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode"
)
))
->add("city", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city"
)
))
->add("country", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country"
)
))
->add("title", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title"
)
))
;
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return "thelia_customer_modification";
}
}

View File

@@ -0,0 +1,99 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Model\ConfigQuery;
use Thelia\Model\CustomerQuery;
use Thelia\Core\Translation\Translator;
/**
* Class CustomerPasswordUpdateForm
* @package Thelia\Form
* @author Christophe Laffont <claffont@openstudio.fr>
*/
class CustomerPasswordUpdateForm extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
// Login Information
->add("password_old", "password", array(
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Callback(array("methods" => array(
array($this, "verifyCurrentPasswordField")
)))
),
"label" => Translator::getInstance()->trans("Current Password"),
"label_attr" => array(
"for" => "password_old"
)
))
->add("password", "password", array(
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4)))
),
"label" => Translator::getInstance()->trans("New Password"),
"label_attr" => array(
"for" => "password"
)
))
->add("password_confirm", "password", array(
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))),
new Constraints\Callback(array("methods" => array(
array($this, "verifyPasswordField")
)))
),
"label" => "Password confirmation",
"label_attr" => array(
"for" => "password_confirmation"
)
));
}
public function verifyCurrentPasswordField($value, ExecutionContextInterface $context)
{
}
public function verifyPasswordField($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if ($data["password"] != $data["password_confirm"]) {
$context->addViolation("password confirmation is not the same as password field.");
}
}
public function getName()
{
return "thelia_customer_password_update";
}
}

View File

@@ -0,0 +1,71 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Translation\Translator;
/**
* Class CustomerProfilUpdateForm
* @package Thelia\Form
* @author Christophe Laffont <claffont@openstudio.fr>
*/
class CustomerProfilUpdateForm extends CustomerCreateForm
{
protected function buildForm()
{
parent::buildForm();
$this->formBuilder
->remove("auto_login")
// Remove From Personal Informations
->remove("phone")
->remove("cellphone")
// Remove Delivery Informations
->remove("company")
->remove("address1")
->remove("address2")
->remove("address3")
->remove("city")
->remove("zipcode")
->remove("country")
// Remove Terms & conditions
->remove("agreed")
// Add Newsletter
->add("newsletter", "checkbox", array(
"label" => "I would like to receive the newsletter our the latest news.",
"label_attr" => array(
"for" => "newsletter"
),
"required" => false
));
}
public function getName()
{
return "thelia_customer_profil_update";
}
}

View File

@@ -1,10 +1,10 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
@@ -17,57 +17,146 @@
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Translation\Translator;
/**
* Class CustomerUpdateForm
* @package Thelia\Form
* @author Christophe Laffont <claffont@openstudio.fr>
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CustomerUpdateForm extends CustomerCreation
class CustomerUpdateForm extends BaseForm
{
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->form attribute :
*
* $this->form->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"
* ),
* "label" => "email",
* "constraints" => array(
* new NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
*/
protected function buildForm()
{
parent::buildForm();
$this->formBuilder
->remove("auto_login")
// Remove From Personal Informations
->remove("phone")
->remove("cellphone")
// Remove Delivery Informations
->remove("company")
->remove("address1")
->remove("address2")
->remove("address3")
->remove("city")
->remove("zipcode")
->remove("country")
// Remove Login Information
->remove("password")
->remove("password_confirm")
// Remove Terms & conditions
->remove("agreed")
// Add Newsletter
->add("newsletter", "checkbox", array(
"label" => "I would like to receive the newsletter our the latest news.",
->add('update_logged_in_user', 'integer') // In a front office context, update the in-memory logged-in user data
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Company"),
"label_attr" => array(
"for" => "newsletter"
"for" => "company"
)
))
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"required" => false
));
"label" => Translator::getInstance()->trans("First Name"),
"label_attr" => array(
"for" => "firstname"
)
))
->add("lastname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Last Name"),
"label_attr" => array(
"for" => "lastname"
)
))
->add("address1", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label_attr" => array(
"for" => "address"
),
"label" => Translator::getInstance()->trans("Street Address")
))
->add("address2", "text", array(
"label" => Translator::getInstance()->trans("Address Line 2"),
"label_attr" => array(
"for" => "address2"
)
))
->add("address3", "text", array(
"label" => Translator::getInstance()->trans("Address Line 3"),
"label_attr" => array(
"for" => "address3"
)
))
->add("phone", "text", array(
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone"
)
))
->add("cellphone", "text", array(
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode"
)
))
->add("city", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city"
)
))
->add("country", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country"
)
))
->add("title", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title"
)
))
;
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return "thelia_customer_update";

View File

@@ -1,6 +1,6 @@
{* Update an Address *}
{form name="thelia.address.update"}
{form name="thelia.admin.address.update"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "edit_address_dialog"}

View File

@@ -28,7 +28,7 @@
<div class="form-container">
<div class="col-md-12">
{form name="thelia.customer.modification"}
{form name="thelia.admin.customer.modification"}
<form method="POST" action="{url path="/admin/customer/update/{$ID}"}" {form_enctype form=$form} class="clearfix">
<div class="row inner-toolbar clearfix">
@@ -221,7 +221,7 @@
<div id="address-update-modal"></div>
{* Add an Address *}
{form name="thelia.address.create"}
{form name="thelia.admin.address.create"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "address_creation_dialog"}

View File

@@ -161,7 +161,7 @@
{* Adding a new Category *}
{form name="thelia.customer.creation"}
{form name="thelia.admin.customer.create"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "customer_creation_dialog"}

View File

@@ -19,7 +19,7 @@
<h1 id="main-label" class="page-header">{intl l="Update Profil"}</h1>
{form name="thelia.customer.update"}
{form name="thelia.front.customer.profil.update"}
{assign var="isPost" value="{$smarty.post|count}"}
<form id="form-register" class="form-horizontal" action="{url path="/account/update"}" method="post" role="form">
{form_field form=$form field='success_url'}

View File

@@ -21,7 +21,7 @@
<article class="col-main" role="main" aria-labelledby="main-label">
<h1 id="main-label" class="page-header">{intl l="Create New Address"}</h1>
{form name="thelia.address.update"}
{form name="thelia.front.address.update"}
{loop name="customer.update" type="address" customer="current" id="{$address_id}"}
<form id="form-address" class="form-horizontal" action="{url path="/address/update/{$address_id}"}" method="post" role="form">
{form_field form=$form field='success_url'}

View File

@@ -21,7 +21,7 @@
<article class="col-main" role="main" aria-labelledby="main-label">
<h1 id="main-label" class="page-header">{intl l="Create New Address"}</h1>
{form name="thelia.address.create"}
{form name="thelia.front.address.create"}
<form id="form-address" class="form-horizontal" action="{url path="/address/create"}" method="post" role="form">
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path="/account"}" /> {* the url the user is redirected to on login success *}

View File

@@ -76,7 +76,7 @@ URL: http://www.thelia.net
<li class="dropdown">
<a href="{url path="/login"}" class="login">{intl l="Log In!"}</a>
<div class="dropdown-menu">
{form name="thelia.customer.login"}
{form name="thelia.front.customer.login"}
<form id="form-login-mini" action="{url path="/login"}" method="post" role="form" {form_enctype form=$form}>
{form_hidden_fields form=$form}
{form_field form=$form field="email"}

View File

@@ -15,8 +15,8 @@
<div class="main">
<article class="col-main" role="main" aria-labelledby="main-label">
<h1 id="main-label" class="page-header">{intl l="Login"}</h1>
{form name="thelia.customer.login"}
<form id="form-login" action="{url path="/login"}" method="post" role="form" {form_enctype form=$form}>
{form name="thelia.front.customer.login"}
<form id="form-login" action="{url path="/login"}" method="post" role="form" {form_enctype form=$form} novalidate>
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
{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 *}

View File

@@ -15,7 +15,7 @@
<div class="main">
<article class="col-main" role="main" aria-labelledby="main-label">
<h1 id="main-label" class="page-header">{intl l="Password Forgotten"}</h1>
{form name="thelia.customer.lostpassword"}
{form name="thelia.front.customer.lostpassword"}
<form id="form-forgotpassword" action="{url path="/password"}" method="post" role="form">
<p>{intl l="Please enter your email address below."} {intl l="You will receive a link to reset your password."}</p>

View File

@@ -14,7 +14,7 @@
<article class="col-main" role="main" aria-labelledby="main-label">
<h1 id="main-label" class="page-header">{intl l="Create New Account"}</h1>
{form name="thelia.customer.creation"}
{form name="thelia.front.customer.create"}
<form id="form-register" class="form-horizontal" action="{url path="/register"}" method="post" role="form">
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path="/account"}" /> {* the url the user is redirected to on registration success *}