Refactored Form system to get simple error handling and a clearer

interface
This commit is contained in:
franck
2013-07-16 16:34:47 +02:00
parent d250e0c660
commit e8bf47b929
26 changed files with 626 additions and 220 deletions

View File

@@ -43,10 +43,9 @@ class Customer implements EventSubscriberInterface
$request = $event->getRequest();
$customerForm = new CustomerCreation($request);
$form = $customerForm->getForm();
$customerCreation = new CustomerCreation($request);
$form = $customerCreation->getForm();
if ($request->isMethod("post")) {
$form->bind($request);
@@ -68,18 +67,18 @@ class Customer implements EventSubscriberInterface
$data["country"],
$data["email"],
$data["password"],
$request->getSession()->get("lang")
$request->getSession()->getLang()
);
} catch (\PropelException $e) {
Tlog::getInstance()->error(sprintf('error during creating customer on action/createCustomer with message "%s"', $e->getMessage()));
$event->setFormError($form);
$event->setFormError($customerCreation);
}
//Customer is create, he is automatically connected
} else {
$event->setFormError($form);
$event->setFormError($customerCreation);
}
}
@@ -117,10 +116,10 @@ class Customer implements EventSubscriberInterface
);
} catch(\PropelException $e) {
Tlog::getInstance()->error(sprintf('error during modifying customer on action/modifyCustomer with message "%s"', $e->getMessage()));
$event->setFormError($form);
$event->setFormError($customerModification);
}
} else {
$event->setFormError($form);
$event->setFormError($customerModification);
}
}