mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 05:09:06 +02:00
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:
parent
693c2a3c51
commit
b81f0be92a
@ -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) {
|
function saveInto(DataObject $record) {
|
||||||
$fieldname = $this->name ;
|
$fieldname = $this->name ;
|
||||||
|
|
||||||
if($fieldname && $record && ($record->has_many($fieldname) || $record->many_many($fieldname))) {
|
if($fieldname && $record && ($record->has_many($fieldname) || $record->many_many($fieldname))) {
|
||||||
$record->$fieldname()->setByIDList($this->value);
|
$record->$fieldname()->setByIDList($this->value);
|
||||||
} else if($fieldname && $record && $record->hasField($fieldname)) {
|
} elseif($fieldname && $record) {
|
||||||
if($this->value){
|
if($this->value) {
|
||||||
$this->value = str_replace(",", "{comma}", $this->value);
|
$this->value = str_replace(",", "{comma}", $this->value);
|
||||||
$record->$fieldname = implode(",", $this->value);
|
$record->$fieldname = implode(",", $this->value);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user