Merged revisions 50641,50645,50815 via svnmerge from

svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk

........
  r50641 | mrickerby | 2008-03-06 14:21:47 +1300 (Thu, 06 Mar 2008) | 1 line
  
  fixing typo in parameter name $validate --> $validator
........
  r50645 | mrickerby | 2008-03-06 15:06:47 +1300 (Thu, 06 Mar 2008) | 1 line
  
  made $messageType parameter of Validator::validationError optional, and added API docs to explain what (apparently) is going on
........
  r50815 | mrickerby | 2008-03-11 10:48:13 +1300 (Tue, 11 Mar 2008) | 1 line
  
  fixing bug with in-memory child objects not having their parent ID field updated via the ->add() method
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2.2@50909 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-03-11 22:54:27 +00:00
parent e0a1e7cdbe
commit 9d902aa8cd
4 changed files with 24 additions and 4 deletions

View File

@ -124,6 +124,7 @@ class ComponentSet extends DataObjectSet {
protected function loadChildIntoDatabase($item, $extraFields = null) {
if($this->type == '1-to-many') {
$child = DataObject::get_by_id($this->childClass,$item->ID);
if (!$child) $child = $item;
$joinField = $this->joinField;
$child->$joinField = $this->ownerObj->ID;
$child->write();

View File

@ -105,7 +105,7 @@ JS;
}
function validate( $validate ) {
function validate( $validator ) {
$result = DB::query(sprintf(
"SELECT COUNT(*) FROM `%s` WHERE `%s` = '%s'",

View File

@ -361,10 +361,19 @@ HTML;
}
/**
* Validation Functions for each field type by default
* formfield doesnt have a validation function
* javascript handler Functions for each field type by default
* formfield doesnt have a validation function
*
* @todo shouldn't this be an abstract method?
*/
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;}
/**

View File

@ -8,8 +8,11 @@
/**
* This validation class handles all form and custom form validation through
* the use of Required fields.
*
* 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
* FormResponse if the request was made by ajax.
*
@ -37,7 +40,14 @@ abstract class Validator extends Object {
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(
'fieldName' => $fieldName,
'message' => $message,