silverstripe-framework/forms/CustomValidator.php

27 lines
560 B
PHP
Raw Normal View History

<?php
/**
* Custom javascript validation
* @package forms
* @subpackage validators
* @deprecated How is this better than / different from {@link CustomRequiredFields}?
*/
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;
}
}
?>