mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-29 20:59:23 +02:00
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
This commit is contained in:
parent
920fd71a2f
commit
4e36020118
@ -181,7 +181,7 @@ class CheckboxSetField extends OptionsetField {
|
|||||||
public function saveInto(DataObjectInterface $record) {
|
public function saveInto(DataObjectInterface $record) {
|
||||||
$fieldname = $this->name;
|
$fieldname = $this->name;
|
||||||
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
|
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
|
||||||
if($fieldname && $record && $relation && $relation instanceof RelationList) {
|
if($fieldname && $record && $relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
|
||||||
$idList = array();
|
$idList = array();
|
||||||
if($this->value) foreach($this->value as $id => $bool) {
|
if($this->value) foreach($this->value as $id => $bool) {
|
||||||
if($bool) {
|
if($bool) {
|
||||||
|
@ -179,7 +179,7 @@ class ListboxField extends DropdownField {
|
|||||||
if($this->multiple) {
|
if($this->multiple) {
|
||||||
$fieldname = $this->name;
|
$fieldname = $this->name;
|
||||||
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
|
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
|
||||||
if($fieldname && $record && $relation && $relation instanceof RelationList) {
|
if($fieldname && $record && $relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
|
||||||
$idList = (is_array($this->value)) ? array_values($this->value) : array();
|
$idList = (is_array($this->value)) ? array_values($this->value) : array();
|
||||||
if(!$record->ID) {
|
if(!$record->ID) {
|
||||||
$record->write(); // record needs to have an ID in order to set relationships
|
$record->write(); // record needs to have an ID in order to set relationships
|
||||||
|
Loading…
Reference in New Issue
Block a user