mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR make sure DataObject::setField() can only be pased a scalar, or a DBField.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@82486 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
77ab3e6038
commit
d5d8cf15f6
@ -1974,11 +1974,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @param mixed $val New field value
|
||||
*/
|
||||
function setField($fieldName, $val) {
|
||||
// Situation 1: Passing a DBField
|
||||
// Situation 1: Passing an object
|
||||
if(is_object($val)) {
|
||||
if($val instanceof DBField) {
|
||||
$val->Name = $fieldName;
|
||||
$this->record[$fieldName] = $val;
|
||||
|
||||
} else {
|
||||
user_error('DataObject::setField: passed an object that is not a DBField', E_USER_WARNING);
|
||||
}
|
||||
// Situation 2: Passing a literal
|
||||
} else {
|
||||
$defaults = $this->stat('defaults');
|
||||
|
Loading…
Reference in New Issue
Block a user