From cf7adf02da888ac947e6d4fe33197e531b8f86ad Mon Sep 17 00:00:00 2001 From: Romain Louis Date: Wed, 17 Oct 2007 22:48:17 +0000 Subject: [PATCH] Saving bug fixing with when value equals undefined git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43536 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/HasOneComplexTableField.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/forms/HasOneComplexTableField.php b/forms/HasOneComplexTableField.php index 1f7ccd782..81b1d4249 100644 --- a/forms/HasOneComplexTableField.php +++ b/forms/HasOneComplexTableField.php @@ -85,12 +85,13 @@ class HasOneComplexTableField extends ComplexTableField { function saveInto( DataObject $record ) { $fieldName = $this->name; $fieldNameID = $fieldName . 'ID'; - - if( $val = $this->value[ $this->htmlListField ] ) - $record->$fieldNameID = $val; - else - $record->$fieldNameID = 0; - + + $record->$fieldNameID = 0; + if( $val = $this->value[ $this->htmlListField ] ) { + if( $val != 'undefined' ) + $record->$fieldNameID = $val; + } + $record->write(); }