Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2816 fix #2945 フォームのファイルフィールドの問題を修正 #2957

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/baser-core/src/Utility/BcFileUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,11 @@ public function moveFileSessionToTmp($data, $fieldName)
$uploadInfo['uploadable'] = true;
$uploadInfo['ext'] = BcUtil::decodeContent($fileType, $fileName);
$uploadedFile[$fieldName] = $uploadInfo;

// 一時ファイルを一度に複数扱う場合に1ファイルしかアップロードされない問題への対応
// 例: メールフォームのファイルフィールドなど
$uploadedFile = array_merge($this->getUploadingFiles($data['_bc_upload_id']), $uploadedFile);

$this->setUploadingFiles($uploadedFile, $data['_bc_upload_id']);
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions plugins/baser-core/src/View/Helper/BcUploadHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ public function fileLink($fieldName, $entity, $options = [])
$basePath = '/baser-core/uploads/tmp/';
}

if (is_array($value)) {
return false;
}

/* ファイルのパスを取得 */
/* 画像の場合はサイズを指定する */
if (isset($settings['saveDir'])) {
Expand Down
13 changes: 6 additions & 7 deletions plugins/bc-mail/src/Service/MailMessagesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,13 @@ public function getIndex(array $queryParams = [])
*/
public function create(EntityInterface $mailContent, $postData)
{
if (!$postData instanceof EntityInterface) {
// newEntity() だと配列が消えてしまうため、エンティティクラスで直接変換
$entity = new MailMessage($postData, ['source' => 'BcMail.MailMessages']);
} else {
$entity = $postData;
$entity = $this->MailMessages->newEntity($postData);
foreach ($postData as $postKey => $postValue) {
if (is_array($postValue)) {
$entity->$postKey = $postValue;
}
}
$validateEntity = $this->MailMessages->patchEntity($this->MailMessages->newEmptyEntity(), $entity->toArray());
if (!$validateEntity->getErrors()) {
if (!$entity->getErrors()) {
$mailFieldsTable = TableRegistry::getTableLocator()->get('BcMail.MailFields');
$mailFields = $mailFieldsTable->find()->where(['MailFields.mail_content_id' => $mailContent->id, 'MailFields.use_field' => true])->all();
$this->MailMessages->convertToDb($mailFields, $entity);
Expand Down