Skip to content

Commit

Permalink
BUGFIX Setting level in DataObject->getChangedFields() to 'value chan…
Browse files Browse the repository at this point in the history
…ge' rather than 'type change' for CompositeFields, so they save correctly (fixes #6726, thanks frankmullenger)
  • Loading branch information
chillu committed Oct 7, 2011
1 parent dcf5995 commit c630f83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion model/DataObject.php
Expand Up @@ -1979,7 +1979,7 @@ public function getChangedFields($databaseFieldsOnly = false, $changeLevel = 1)
// 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;
}
}

Expand Down
3 changes: 2 additions & 1 deletion tests/model/MoneyTest.php
Expand Up @@ -45,7 +45,8 @@ function testDataObjectChangedFields() {
$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() {
Expand Down

0 comments on commit c630f83

Please sign in to comment.