API CHANGE Deprecated Form->loadNonBlankDataFrom() - it was duplicating loadDataFrom() without allowing for the same options, and it was buggy in its definition of "blank" by doing non-typesafe checks with if($value) $field->setValue($value) which resulted in '0' strings not being loaded

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63764 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-10-07 17:52:27 +00:00
parent 9d405ed4ae
commit 78c052af9e

View File

@ -730,7 +730,6 @@ class Form extends RequestHandlingData {
* @param array|DataObject $data
* @param boolean $loadBlanks Load blank values into the form, overwriting any existing values.
*/
function loadDataFrom($data, $loadBlanks = false) {
if(!is_object($data) && !is_array($data)) {
user_error("Form::loadDataFrom() not passed an array or an object", E_USER_WARNING);
@ -772,24 +771,10 @@ class Form extends RequestHandlingData {
}
/**
* Load data from the given object.
* It will call $object->MyField to get the value of MyField.
* If you passed an array, it will call $object[MyField].
* @deprecated 2.3 Use loadDataFrom()
*/
function loadNonBlankDataFrom($object) {
$this->record = $object;
if(is_object($object)) $o = true;
else if(is_array($object)) $o = false;
else {
user_error("Form::loadDataFrom() not passed an array or an object", E_USER_WARNING);
return;
}
$dataFields = $this->fields->dataFields();
if($dataFields) foreach($dataFields as $field) {
$name = $field->Name();
$val = $o ? $object->$name : (isset($object[$name]) ? $object[$name] : null);
if($name && $val) $field->setValue($val);
}
function loadNonBlankDataFrom($data) {
return $this->loadDataFrom($data);
}
/**