From 861d4128dc8fae2880ce0161cec3857834f96c44 Mon Sep 17 00:00:00 2001 From: colymba Date: Wed, 5 Sep 2012 20:07:55 +0300 Subject: [PATCH] FIX: update methode now saves has_ fields --- code/GridFieldBulkImageUpload_Request.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/code/GridFieldBulkImageUpload_Request.php b/code/GridFieldBulkImageUpload_Request.php index 986aca0..5bdaeca 100644 --- a/code/GridFieldBulkImageUpload_Request.php +++ b/code/GridFieldBulkImageUpload_Request.php @@ -334,17 +334,19 @@ class GridFieldBulkImageUpload_Request extends RequestHandler { * @return string */ public function update(SS_HTTPRequest $request) - { - $data = $this->getParsedPostData($request->requestVars()); - - $recordClass = $this->gridField->list->dataClass; - $record = DataObject::get_by_id($recordClass, $data['ID']); + { + $data = $this->getParsedPostData($request->requestVars()); + $record = DataObject::get_by_id($this->gridField->list->dataClass, $data['ID']); foreach($data as $field => $value) - { - $record->setField($field, $value); - } - + { + if ( $record->hasMethod($field) ) { + $list = $record->$field(); + $list->setByIDList( $value ); + }else{ + $record->setCastedField($field, $value); + } + } $record->write(); return '{done:1,recordID:'.$data['ID'].'}';