![]() |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Ah, one small thing. The second argument should have a default value, so that it is compatible with the interface - that is, so that you can call it with just one argument. So:
Code:
public function isValid($value, $formData = null) {...}
|
|
|||
|
You're welcome. Anyway, I came across a blog post about the topic of validating multiple elements with dependencies between them. The author has a point, stating that it would be logical that if validation depends on more than an element itself, it should be done in the form. This is some sample code to check two password fields ("password" and "repeat password" must be the same):
Code:
class MyForm extends Zend_Form {
//...
public function isValid($data) {
$ret = parent::isValid($data);
if ($this->password->getValue() != $this->repeatPassword->getValue()) {
$this->repeatPassword->addError("Passwords do not match");
return false;
}
return $ret;
}
}
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| Designed by: Miner Skinz |
Powered by vBulletin® Version 3.8.4 Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Search Engine Friendly URLs by vBSEO 3.1.0 |
![]() |