Permalink
Browse files

MINOR Re-fetching relationship in ListboxField->saveInto() when deali…

…ng with new records, to avoid errors on RelationList without foreign keys (fixes #6925)
  • Loading branch information...
1 parent bf6317d commit 1ba5e79e3b766fbc90c0074106185a86fc3be1dd @chillu chillu committed Mar 9, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 forms/ListboxField.php
View
@@ -175,7 +175,10 @@ function saveInto(DataObject $record) {
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
if($fieldname && $record && $relation && $relation instanceof RelationList) {
$idList = (is_array($this->value)) ? array_values($this->value) : array();
- if(!$record->ID) $record->write(); // record needs to have an ID in order to set relationships
+ if(!$record->ID) {
+ $record->write(); // record needs to have an ID in order to set relationships
+ $relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
+ }
$relation->setByIDList($idList);
} elseif($fieldname && $record) {
if($this->value) {

0 comments on commit 1ba5e79

Please sign in to comment.