From e13413e49c1d1037f7d21a71c9235509c807cc69 Mon Sep 17 00:00:00 2001 From: Lucas Vieira Date: Mon, 1 Sep 2014 19:19:35 -0300 Subject: [PATCH 1/2] The camelize wasn't allowing the isMultiple to return true. --- Model/Behavior/UploadBehavior.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Model/Behavior/UploadBehavior.php b/Model/Behavior/UploadBehavior.php index e637612..3e85575 100644 --- a/Model/Behavior/UploadBehavior.php +++ b/Model/Behavior/UploadBehavior.php @@ -73,7 +73,6 @@ public function setup(Model $model, $config = array()) { * @return void */ protected function _setRelationModel(Model $model, $type) { - $type = Inflector::camelize($type); $relation = 'hasOne'; //case is defined multiple is a hasMany @@ -81,6 +80,8 @@ protected function _setRelationModel(Model $model, $type) { $relation = 'hasMany'; } + $type = Inflector::camelize($type); + $model->{$relation}['Attachment' . $type] = array( 'className' => 'Attachment', 'foreignKey' => 'foreign_key', From 74bde4c596407e3bb725c0e943a1ef316549c341 Mon Sep 17 00:00:00 2001 From: Lucas Vieira Date: Mon, 1 Sep 2014 19:36:03 -0300 Subject: [PATCH 2/2] I had to add this fourth condition to use the multiple attach file. Without it, the attach was saving only the last file. --- Model/Behavior/UploadBehavior.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Model/Behavior/UploadBehavior.php b/Model/Behavior/UploadBehavior.php index 3e85575..6cec4b7 100644 --- a/Model/Behavior/UploadBehavior.php +++ b/Model/Behavior/UploadBehavior.php @@ -538,6 +538,7 @@ public function saveAttachment(Model $model, $type, $filename, $originalName = n 'foreign_key' => $model->id, 'model' => $model->alias, 'type' => $type, + 'filename LIKE' => '%' . strtolower(pathinfo($filename, PATHINFO_FILENAME)) . '%' ), ) );