Skip to content

Commit 4e36020

Browse files
committed
BUG UnsavedRelationList aren't checked
When saveInto is called on ListboxField and CheckboxsetField, UnsavedRelationList should be an acceptable relationship type. This is leading to relations not being saved on initial creation of Member objects
1 parent 920fd71 commit 4e36020

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

forms/CheckboxSetField.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function setValue($value, $obj = null) {
181181
public function saveInto(DataObjectInterface $record) {
182182
$fieldname = $this->name;
183183
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
184-
if($fieldname && $record && $relation && $relation instanceof RelationList) {
184+
if($fieldname && $record && $relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
185185
$idList = array();
186186
if($this->value) foreach($this->value as $id => $bool) {
187187
if($bool) {

forms/ListboxField.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function saveInto(DataObjectInterface $record) {
179179
if($this->multiple) {
180180
$fieldname = $this->name;
181181
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
182-
if($fieldname && $record && $relation && $relation instanceof RelationList) {
182+
if($fieldname && $record && $relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
183183
$idList = (is_array($this->value)) ? array_values($this->value) : array();
184184
if(!$record->ID) {
185185
$record->write(); // record needs to have an ID in order to set relationships

0 commit comments

Comments
 (0)