2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
|
2008-01-09 05:18:36 +01:00
|
|
|
/**
|
|
|
|
* @package forms
|
|
|
|
* @subpackage validators
|
|
|
|
*/
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
|
|
|
* Custom javascript validation
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage validators
|
|
|
|
* @deprecated How is this better than / different from {@link CustomRequiredFields}?
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class CustomValidator extends Validator {
|
|
|
|
protected $javascriptCode;
|
|
|
|
function __construct($javascriptCode) {
|
|
|
|
$this->javascriptCode = $javascriptCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
function javascript() {
|
|
|
|
return $this->javascriptCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
function php($data) {
|
|
|
|
$valid = true;
|
|
|
|
foreach($this->form->Fields() as $field) {
|
|
|
|
$valid = ($field->validate($this) && $valid);
|
|
|
|
}
|
|
|
|
return $valid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|