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 => "",