BUGFIX Fixed saving a CheckboxSetField value into a field that is not a has_many or many_many relationship. It should be just a comma separated list in a standard text field.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@57092 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2008-06-30 02:55:51 +00:00
parent 693c2a3c51
commit b81f0be92a

View File

@ -106,15 +106,20 @@ class CheckboxSetField extends OptionsetField {
}
/**
* @desc
*/
* Save the current value of this CheckboxSetField into a DataObject.
* If the field it is saving to is a has_many or many_many relationship,
* it is saved by setByIDList(), otherwise it creates a comma separated
* list for a standard DB text/varchar field.
*
* @param DataObject $record The record to save into
*/
function saveInto(DataObject $record) {
$fieldname = $this->name ;
if($fieldname && $record && ($record->has_many($fieldname) || $record->many_many($fieldname))) {
$record->$fieldname()->setByIDList($this->value);
} else if($fieldname && $record && $record->hasField($fieldname)) {
if($this->value){
} elseif($fieldname && $record) {
if($this->value) {
$this->value = str_replace(",", "{comma}", $this->value);
$record->$fieldname = implode(",", $this->value);
} else {