mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Re-fetching relationship in ListboxField->saveInto() when dealing with new records, to avoid errors on RelationList without foreign keys (fixes #6925)
This commit is contained in:
parent
bf6317d534
commit
1ba5e79e3b
@ -175,7 +175,10 @@ class ListboxField extends DropdownField {
|
||||
$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) {
|
||||
|
Loading…
Reference in New Issue
Block a user