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->addHidden('id');
|
||||||
}
|
}
|
||||||
$this->setDefaults($this->object->getProperties());
|
$this->setDefaults($this->object->getProperties());
|
||||||
|
if (! $this->hasBeenSubmitted()) {
|
||||||
|
$this->beforeValidation($this->object->getProperties());
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,10 @@ abstract class QuickForm extends Zend_Form
|
||||||
return $this->hasBeenSent();
|
return $this->hasBeenSent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function beforeValidation($data = array())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function handleRequest(Request $request = null)
|
public function handleRequest(Request $request = null)
|
||||||
{
|
{
|
||||||
if ($request !== null) {
|
if ($request !== null) {
|
||||||
|
@ -121,6 +125,7 @@ abstract class QuickForm extends Zend_Form
|
||||||
if ($this->hasBeenSent()) {
|
if ($this->hasBeenSent()) {
|
||||||
$post = $this->getRequest()->getPost();
|
$post = $this->getRequest()->getPost();
|
||||||
if ($this->hasBeenSubmitted()) {
|
if ($this->hasBeenSubmitted()) {
|
||||||
|
$this->beforeValidation($post);
|
||||||
if ($this->isValid($post)) {
|
if ($this->isValid($post)) {
|
||||||
$this->onSuccess();
|
$this->onSuccess();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue