Skip to content

Commit

Permalink
fix #3098 【5.1】エディタテンプレート新規登録・編集で必須項目を記入せず、アイコン画像を入れ保存するとエラーが発生する【エディ…
Browse files Browse the repository at this point in the history
…タテンプレート】 (#3114)

Co-authored-by: Đỗ Văn Hùng <[email protected]>
  • Loading branch information
HungDV2022 and dovanhung authored Feb 16, 2024
1 parent 7e30e2f commit bb765aa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/baser-core/src/View/Helper/BcFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -865,18 +865,20 @@ public function file($fieldName, $options = []): string

// PHP5.3対応のため、is_string($value) 判別を実行
$delCheckTag = '';
if ($fileLinkTag && $linkOptions['delCheck'] && (is_string($value) || empty($value['session_key']))) {
if ($fileLinkTag && $linkOptions['delCheck'] && (is_string($value) ||
(is_array($value) && empty($value['session_key'])) ||
(is_object($value) && $value->getError() == UPLOAD_ERR_NO_FILE))) {
$delCheckTag = $this->Html->tag('span', $this->checkbox($fieldName . '_delete', $deleteCheckboxOptions) . $this->label($fieldName . '_delete', __d('baser_core', '削除する'), $deleteLabelOptions), $deleteSpanOptions);
}
$hiddenValue = $this->getSourceValue($fieldName . '_');
$fileValue = $this->getSourceValue($fieldName);

$hiddenTag = '';
if ($fileLinkTag) {
if (is_array($fileValue) && empty($fileValue['tmp_name']) && $hiddenValue) {
if (is_object($fileValue) && empty($fileValue->getClientFileName()) && $hiddenValue) {
$hiddenTag = $this->hidden($fieldName . '_', ['value' => $hiddenValue]);
} else {
if (is_array($fileValue)) {
if (is_array($fileValue) || is_object($fileValue)) {
$fileValue = null;
}
$hiddenTag = $this->hidden($fieldName . '_', ['value' => $fileValue]);
Expand Down

0 comments on commit bb765aa

Please sign in to comment.