mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Changed comments in forms\Validator.php
This commit is contained in:
parent
f49c0b58d9
commit
29ee58abc3
@ -1,12 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
* the use of Required fields.
|
* fields. It relies on javascript for client-side validation, and marking fields after server-side
|
||||||
*
|
* validation. It acts as a visitor to individual form fields.
|
||||||
* Relies on javascript for client-side validation, and marking fields after serverside validation.
|
|
||||||
*
|
|
||||||
* Acts as a visitor to individual form fields.
|
|
||||||
*
|
*
|
||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage validators
|
* @subpackage validators
|
||||||
@ -26,7 +23,7 @@ abstract class Validator extends Object {
|
|||||||
/**
|
/**
|
||||||
* @param Form $form
|
* @param Form $form
|
||||||
*
|
*
|
||||||
* @return static
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setForm($form) {
|
public function setForm($form) {
|
||||||
$this->form = $form;
|
$this->form = $form;
|
||||||
@ -48,33 +45,37 @@ abstract class Validator extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to register an error on a field (Called from implementations of {@link FormField::validate})
|
* Callback to register an error on a field (Called from implementations of
|
||||||
*
|
* {@link FormField::validate}). The optional error message type parameter is loaded into the
|
||||||
* @param string $fieldName name of the field
|
* HTML class attribute.
|
||||||
* @param string $message error message to display
|
|
||||||
* @param string $messageType optional parameter, gets loaded into the HTML class attribute in the rendered output.
|
|
||||||
*
|
*
|
||||||
* See {@link getErrors()} for details.
|
* See {@link getErrors()} for details.
|
||||||
|
*
|
||||||
|
* @param string $fieldName
|
||||||
|
* @param string $errorMessage
|
||||||
|
* @param string $errorMessageType
|
||||||
*/
|
*/
|
||||||
public function validationError($fieldName, $message, $messageType = '') {
|
public function validationError($fieldName, $errorMessage, $errorMessageType = '') {
|
||||||
$this->errors[] = array(
|
$this->errors[] = array(
|
||||||
'fieldName' => $fieldName,
|
'fieldName' => $fieldName,
|
||||||
'message' => $message,
|
'message' => $errorMessage,
|
||||||
'messageType' => $messageType,
|
'messageType' => $errorMessageType,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all errors found by a previous call to {@link validate()}.
|
* Returns all errors found by a previous call to {@link validate()}. The returned array has a
|
||||||
|
* structure resembling:
|
||||||
*
|
*
|
||||||
* The array contains the following keys for each error:
|
* <code>
|
||||||
* - 'fieldName': the name of the FormField instance
|
* array(
|
||||||
* - 'message': Validation message (optionally localized)
|
* 'fieldName' => '[form field name]',
|
||||||
* - 'messageType': Arbitrary type of the message which is rendered as a CSS class in the FormField template,
|
* 'message' => '[validation error message]',
|
||||||
* e.g. <span class="message (type)">. Usually "bad|message|validation|required", which renders differently
|
* 'messageType' => '[bad|message|validation|required]',
|
||||||
* if framework/css/Form.css is included.
|
* )
|
||||||
|
* </code>
|
||||||
*
|
*
|
||||||
* @return array
|
* @return null|array
|
||||||
*/
|
*/
|
||||||
public function getErrors() {
|
public function getErrors() {
|
||||||
return $this->errors;
|
return $this->errors;
|
||||||
@ -105,11 +106,12 @@ abstract class Validator extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the named field is "required".
|
* Returns whether the field in question is required. This will usually display '*' next to the
|
||||||
|
* field. The base implementation always returns false.
|
||||||
*
|
*
|
||||||
* Used by FormField to return a value for FormField::Required(), to do things like show *s on the form template.
|
* @param string $fieldName
|
||||||
*
|
*
|
||||||
* By default, it always returns false.
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function fieldIsRequired($fieldName) {
|
public function fieldIsRequired($fieldName) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user