From 0bd1ec9d04ebb14c762a0853f0dde43ba331d3f0 Mon Sep 17 00:00:00 2001 From: wolfcode <37436228+wolf-leo@users.noreply.github.com> Date: Mon, 20 Nov 2023 12:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E5=85=BC=E5=AE=B9cu?= =?UTF-8?q?rd=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/curd/BuildCurd.php | 9 +++++---- app/admin/service/curd/templates/view/module/editor.code | 3 ++- app/common.php | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/admin/service/curd/BuildCurd.php b/app/admin/service/curd/BuildCurd.php index 1b76f31..565f5bb 100644 --- a/app/admin/service/curd/BuildCurd.php +++ b/app/admin/service/curd/BuildCurd.php @@ -872,7 +872,7 @@ class BuildCurd } // 判断富文本 - if (in_array($field, $this->editorFields)) { + if (in_array($field, $this->editorFields) || in_array($val['type'], ['text', 'tinytext', 'mediumtext', 'longtext'])) { $this->tableColumns[$field]['formType'] = 'editor'; continue; } @@ -940,7 +940,7 @@ class BuildCurd } // 判断富文本 - if (in_array($field, $this->editorFields)) { + if (in_array($field, $this->editorFields) || in_array($val['type'], ['text', 'tinytext', 'mediumtext', 'longtext'])) { $this->relationArray[$table]['tableColumns'][$field]['formType'] = 'editor'; continue; } @@ -1146,7 +1146,8 @@ class BuildCurd $templateFile = "view{$this->DS}module{$this->DS}files"; $define = isset($val['define']) ? $val['define'] : '|'; } elseif ($val['formType'] == 'editor') { - $templateFile = "view{$this->DS}module{$this->DS}editor"; + $templateFile = "view{$this->DS}module{$this->DS}editor"; + $val['default'] = '""'; } elseif ($val['formType'] == 'date') { $templateFile = "view{$this->DS}module{$this->DS}date"; if (isset($val['define']) && !empty($val['define'])) { @@ -1221,7 +1222,7 @@ class BuildCurd $templateFile = "view{$this->DS}module{$this->DS}files"; } elseif ($val['formType'] == 'editor') { $templateFile = "view{$this->DS}module{$this->DS}editor"; - $value = '{$row.' . $field . '|raw|default=\'\'}'; + $value = '$row["' . $field . '"]'; } elseif ($val['formType'] == 'date') { $templateFile = "view{$this->DS}module{$this->DS}date"; if (isset($val['define']) && !empty($val['define'])) { diff --git a/app/admin/service/curd/templates/view/module/editor.code b/app/admin/service/curd/templates/view/module/editor.code index cbd88dc..d58e2d5 100644 --- a/app/admin/service/curd/templates/view/module/editor.code +++ b/app/admin/service/curd/templates/view/module/editor.code @@ -2,6 +2,7 @@
- + {:editor_textarea({{value}},"{{field}}","{{comment}}")} +
\ No newline at end of file diff --git a/app/common.php b/app/common.php index 5c8bb6c..7b2396c 100644 --- a/app/common.php +++ b/app/common.php @@ -130,7 +130,7 @@ if (!function_exists('auth')) { function editor_textarea($row, string $name = 'desc', string $placeholder = '请输入'): string { $editor_type = sysconfig('site', 'editor_type'); - $detail = $row[$name] ?? ''; + $detail = is_array($row) ? ($row[$name] ?? '') : $row; return match ($editor_type) { 'ckeditor' => "", default => "",