From 78c052af9e5523e57e95ea1d2c1b7166740a18e2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 7 Oct 2008 17:52:27 +0000 Subject: [PATCH] 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 --- forms/Form.php | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/forms/Form.php b/forms/Form.php index dde5f15eb..c41ad12b5 100644 --- a/forms/Form.php +++ b/forms/Form.php @@ -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); } /**