Merge pull request #1204 from dhensby/unsavedrelationlist-improvements

BUG UnsavedRelationList aren't checked
This commit is contained in:
Ingo Schommer 2013-03-18 13:43:41 -07:00
commit 2a73b370d0
2 changed files with 2 additions and 2 deletions

View File

@ -181,7 +181,7 @@ class CheckboxSetField extends OptionsetField {
public function saveInto(DataObjectInterface $record) {
$fieldname = $this->name;
$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();
if($this->value) foreach($this->value as $id => $bool) {
if($bool) {

View File

@ -179,7 +179,7 @@ class ListboxField extends DropdownField {
if($this->multiple) {
$fieldname = $this->name;
$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();
if(!$record->ID) {
$record->write(); // record needs to have an ID in order to set relationships