From 6e8b1891bb9ac84784a1e81f54713334db28b06a Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Fri, 25 Sep 2026 20:21:40 +0800 Subject: [PATCH] =?UTF-8?q?feat=E2=9C=A8:=20let=20a=20generated=20page=20c?= =?UTF-8?q?reate=20a=20record=20keyed=20on=20a=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generated form never showed the key column, which is right for a key the database assigns and left a string key with nowhere to be typed: a table keyed on one could be created through the API but not from its page. For a string key the form now carries an input for it, required, and disabled once the record exists - bound to form.isEdit, the same way the hand-written dictionary and config pages lock their natural keys. A page for a table keyed on an int renders exactly as before. This needs go-admin-ui's useForm to record whether a form was opened to create or to edit (go-admin-ui#310). The useForm before it inferred the mode from the key's presence, so typing the key into a create form turned the submit into an update. --- template/v4/vue.go.template | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/template/v4/vue.go.template b/template/v4/vue.go.template index 2b1e43f1..6b72c465 100644 --- a/template/v4/vue.go.template +++ b/template/v4/vue.go.template @@ -66,7 +66,7 @@ {{- if and (eq .IsList "1") (eq .FkTableName "") (eq .DictType "") (eq .HtmlType "datetime") }}{{$hasDatetime = true}}{{end -}} {{- if eq .IsQuery "1" }}{{$hasQuery = true}}{{end -}} {{- if and (eq .IsInsert "1") (eq .IsRequired "1") (not .Pk) (ne .GoField "CreatedAt") (ne .GoField "UpdatedAt") (ne .GoField "DeletedAt") (ne .GoField "UpdateBy") (ne .GoField "CreateBy") }}{{$hasRules = true}}{{end -}} - {{- if and .Pk (eq .GoType "string") }}{{$pkType = "string"}}{{end -}} + {{- if and .Pk (eq .GoType "string") }}{{$pkType = "string"}}{{$hasRules = true}}{{end -}} {{- end -}}