QuickForm: add preValidation hook
Allows to modify form properties depending on submitted values before validating them
This commit is contained in:
parent
b4fdb6b64e
commit
88d87b1e5c
|
@ -96,6 +96,9 @@ abstract class DirectorObjectForm extends QuickForm
|
|||
$this->addHidden('id');
|
||||
}
|
||||
$this->setDefaults($this->object->getProperties());
|
||||
if (! $this->hasBeenSubmitted()) {
|
||||
$this->beforeValidation($this->object->getProperties());
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,10 @@ abstract class QuickForm extends Zend_Form
|
|||
return $this->hasBeenSent();
|
||||
}
|
||||
|
||||
protected function beforeValidation($data = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function handleRequest(Request $request = null)
|
||||
{
|
||||
if ($request !== null) {
|
||||
|
@ -121,6 +125,7 @@ abstract class QuickForm extends Zend_Form
|
|||
if ($this->hasBeenSent()) {
|
||||
$post = $this->getRequest()->getPost();
|
||||
if ($this->hasBeenSubmitted()) {
|
||||
$this->beforeValidation($post);
|
||||
if ($this->isValid($post)) {
|
||||
$this->onSuccess();
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue