Changeset 57099

Show
Ignore:
Timestamp:
30/06/08 14:55:51 (2 months ago)
Author:
sharvey
Message:

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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • modules/sapphire/trunk/forms/CheckboxSetField.php

    r56219 r57099  
    107107         
    108108        /** 
    109         * @desc  
    110         */ 
     109         * Save the current value of this CheckboxSetField into a DataObject. 
     110         * If the field it is saving to is a has_many or many_many relationship, 
     111         * it is saved by setByIDList(), otherwise it creates a comma separated 
     112         * list for a standard DB text/varchar field. 
     113         * 
     114         * @param DataObject $record The record to save into 
     115         */ 
    111116        function saveInto(DataObject $record) { 
    112117                $fieldname = $this->name ; 
     
    114119                if($fieldname && $record && ($record->has_many($fieldname) || $record->many_many($fieldname))) { 
    115120                        $record->$fieldname()->setByIDList($this->value); 
    116                 } else if($fieldname && $record && $record->hasField($fieldname)) { 
    117                         if($this->value){ 
     121                } elseif($fieldname && $record) { 
     122                        if($this->value) { 
    118123                                $this->value = str_replace(",", "{comma}", $this->value); 
    119124                                $record->$fieldname = implode(",", $this->value);