BUGFIX Setting level in DataObject->getChangedFields() to 'value change' rather than 'type change' for CompositeFields, so they save correctly (fixes #6726, thanks frankmullenger)

This commit is contained in:
Ingo Schommer 2011-10-07 17:35:25 +02:00
parent dcf59959d8
commit c630f83344
2 changed files with 3 additions and 2 deletions

View File

@ -1979,7 +1979,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
// Update the changed array with references to changed obj-fields
foreach($this->record as $k => $v) {
if(is_object($v) && method_exists($v, 'isChanged') && $v->isChanged()) {
$this->changed[$k] = 1;
$this->changed[$k] = 2;
}
}

View File

@ -45,7 +45,8 @@ class MoneyTest extends SapphireTest {
$this->assertType('Money', $obj->MyMoney);
$obj->MyMoney->setAmount(99);
$changed = $obj->getChangedFields();
$this->assertContains('MyMoney', array_keys($changed));
$this->assertContains('MyMoney', array_keys($changed), 'Field is detected as changed');
$this->assertEquals(2, $changed['MyMoney']['level'], 'Correct change level');
}
function testCanOverwriteSettersWithNull() {