update create customer form

This commit is contained in:
Manuel Raynaud
2013-07-01 15:39:58 +02:00
parent 762b5bc71c
commit 6e29294418
3 changed files with 52 additions and 12 deletions

View File

@@ -25,6 +25,7 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\BaseForm;
use Thelia\Form\CustomerCreation;
@@ -33,6 +34,9 @@ class Customer implements EventSubscriberInterface
public function create(ActionEvent $event)
{
$event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CREATECUSTOMER, $event);
$request = $event->getRequest();
$customerForm = new CustomerCreation($request);
@@ -49,6 +53,8 @@ class Customer implements EventSubscriberInterface
$event->setFormError($form);
}
}
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECUSTOMER, $event);
}
public function modify(ActionEvent $event)

View File

@@ -47,4 +47,8 @@ final class TheliaEvents
* Send before starting thelia inclusion
*/
const INCLUSION = "thelia.include";
const BEFORE_CREATECUSTOMER = "action.before_createcustomer";
const AFTER_CREATECUSTOMER = "action.after_createcustomer";
}

View File

@@ -24,7 +24,8 @@ namespace Thelia\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints;
use Thelia\Model\ConfigQuery;
class CustomerCreation extends BaseForm
@@ -32,18 +33,47 @@ class CustomerCreation extends BaseForm
protected function buildForm()
{
$this->form->add("name", "text")
->add("email", "email", array(
"attr" => array(
"class" => "field"
),
"label" => "email",
"constraints" => array(
new NotBlank()
)
$this->form
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
)
)
->add('age', 'integer');
))
->add("lastname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
)
))
->add("email", "email", array(
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Email()
)
))
->add("address1", "text", array(
"constraints" => array(
new Constraints\NotBlank()
)
))
->add("address2", "text")
->add("address3", "text")
->add("zipcode", "text", array(
"constraints" => array(
new Constraints\NotBlank()
)
))
->add("country", "text", array(
"constraints" => array(
new Constraints\NotBlank()
)
))
->add("password", "password", array(
"constraints" => array(
new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4)))
)
))
;
}
public function getName()