From 88ed4191ef81c2457e5b19dcdd068f482b6ecbad Mon Sep 17 00:00:00 2001 From: touffies Date: Wed, 16 Oct 2013 09:36:19 +0200 Subject: [PATCH] Fix conflict --- core/lib/Thelia/Form/CustomerLogin.php | 35 ++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php index 4948586d7..79539c19a 100755 --- a/core/lib/Thelia/Form/CustomerLogin.php +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -46,18 +46,23 @@ class CustomerLogin extends BaseForm new Constraints\Email(), new Constraints\Callback(array( "methods" => array( - array($this, - "verifyExistingEmail") + array($this, "verifyExistingEmail") ) )) ), "label" => Translator::getInstance()->trans("Please enter your email address"), "label_attr" => array( "for" => "email" - ), - "required" => true + ) )) ->add("account", "choice", 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 :") @@ -68,14 +73,34 @@ class CustomerLogin extends BaseForm "data" => 0 )) ->add("password", "password", array( + /*"constraints" => array( + new Constraints\NotBlank() + ),*/ "label" => Translator::getInstance()->trans("Please enter your password"), "label_attr" => array( "for" => "password" ), - 'required' => false + "required" => false )); } + /** + * If the user select "Yes, I have a password", we check the password. + */ + public function verifyAccount($value, ExecutionContextInterface $context) + { + if ($value == 1) { + $data = $context->getRoot()->getData(); + + //$context->validate('password', array(new Constraints\NotBlank()) ); + + if (false === $data['password'] || (empty($data['password']) && '0' != $data['password'])) { + $context->addViolationAt("password", "This value should not sssbe blank"); + } + } + } + + /** * If the user select "I'am a new customer", we make sure is email address does not exit in the database. */