made $messageType parameter of Validator::validationError optional, and added API docs to explain what (apparently) is going on

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@50638 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Mark Rickerby 2008-03-06 02:06:47 +00:00
parent 79835098b0
commit 0a543a9ae1
2 changed files with 22 additions and 3 deletions

View File

@ -361,10 +361,19 @@ HTML;
} }
/** /**
* Validation Functions for each field type by default * javascript handler Functions for each field type by default
* formfield doesnt have a validation function * formfield doesnt have a validation function
*
* @todo shouldn't this be an abstract method?
*/ */
function jsValidation() {} function jsValidation() {}
/**
* Validation Functions for each field type by default
* formfield doesnt have a validation function
*
* @todo shouldn't this be an abstract method?
*/
function validate(){return true;} function validate(){return true;}
/** /**

View File

@ -8,8 +8,11 @@
/** /**
* This validation class handles all form and custom form validation through * This validation class handles all form and custom form validation through
* the use of Required fields. * the use of Required fields.
*
* Relies on javascript for client-side validation, and marking fields after serverside validation. * Relies on javascript for client-side validation, and marking fields after serverside validation.
* *
* Acts as a visitor to individual form fields.
*
* @todo Automatically mark fields after serverside validation and replace the form through * @todo Automatically mark fields after serverside validation and replace the form through
* FormResponse if the request was made by ajax. * FormResponse if the request was made by ajax.
* *
@ -37,7 +40,14 @@ abstract class Validator extends Object {
return $this->errors; return $this->errors;
} }
function validationError($fieldName,$message,$messageType){ /**
* Callback to register an error on a field (Called from implementations of {@link FormField::validate})
*
* @param $fieldName name of the field
* @param $message error message to display
* @param $messageType optional parameter, gets loaded into the HTML class attribute in the rendered output
*/
function validationError($fieldName,$message,$messageType=''){
$this->errors[] = array( $this->errors[] = array(
'fieldName' => $fieldName, 'fieldName' => $fieldName,
'message' => $message, 'message' => $message,