{"record":{"id":"0efcecef1d5123d1","repo":"siyuan-note/siyuan","slug":"new-item-template-field-s-current-time-mode-req","errorCode":null,"errorMessage":"new item template field [%s] current time mode requires date type","messagePattern":"new item template field \\[(.+?)\\] current time mode requires date type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":325,"sourceCode":"\tfieldValues := map[string]*NewItemFieldValue{}\n\tfor keyID, fieldValue := range itemTemplate.FieldValues {\n\t\tkey, err := av.GetKey(keyID)\n\t\tif nil != err || nil == key {\n\t\t\treturn fmt.Errorf(\"new item template field [%s] not found\", keyID)\n\t\t}\n\t\tif !isNewItemTemplateEditableKeyType(key.Type) {\n\t\t\treturn fmt.Errorf(\"new item template field [%s] type [%s] is not editable\", keyID, key.Type)\n\t\t}\n\t\tif nil == fieldValue {\n\t\t\tcontinue\n\t\t}\n\t\tif \"\" == fieldValue.Mode {\n\t\t\tfieldValue.Mode = NewItemFieldValueStatic\n\t\t}\n\t\tswitch fieldValue.Mode {\n\t\tcase NewItemFieldValueCurrentTime:\n\t\t\tif KeyTypeDate != key.Type {\n\t\t\t\treturn fmt.Errorf(\"new item template field [%s] current time mode requires date type\", keyID)\n\t\t\t}\n\t\t\tfieldValue.Value = nil\n\t\tcase NewItemFieldValueStatic:\n\t\t\tif nil == fieldValue.Value {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfieldValue.Value, err = normalizeNewItemTemplateValue(fieldValue.Value, key)\n\t\t\tif nil != err {\n\t\t\t\treturn fmt.Errorf(\"new item template field [%s] value is invalid: %w\", keyID, err)\n\t\t\t}\n\t\t\tif KeyTypeSelect == key.Type || KeyTypeMSelect == key.Type {\n\t\t\t\tfor _, selection := range fieldValue.Value.MSelect {\n\t\t\t\t\tif nil != selection && nil == key.GetOption(selection.Content) {\n\t\t\t\t\t\treturn fmt.Errorf(\"new item template field [%s] option [%s] not found\", keyID, selection.Content)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/new_item_template.go#L307-L343","documentation":"The NewItemFieldValueCurrentTime mode is only meaningful for date-typed fields. When a field value uses the current-time mode on a key whose Type is not KeyTypeDate, normalizeNewItemTemplateFieldValues rejects the configuration. The current-time mode injects the creation timestamp, which requires a date field to store it.","triggerScenarios":"Calling SetNewItemTemplates with FieldValues[keyID].Mode = NewItemFieldValueCurrentTime where the referenced key's Type is not KeyTypeDate (e.g. a text or number field).","commonSituations":"Selecting 'current time' fill mode for a non-date field in a plugin UI; a field's type changed from date to text after the template was saved; copying a field-value config to a differently-typed field.","solutions":["Switch the field value's Mode to NewItemFieldValueStatic for non-date fields","Change the target key to a date-typed field before using NewItemFieldValueCurrentTime","Remove the FieldValues entry if neither applies"],"exampleFix":"// before\nfv.Mode = av.NewItemFieldValueCurrentTime // key is text\n// after\nif key.Type == av.KeyTypeDate {\n\tfv.Mode = av.NewItemFieldValueCurrentTime\n} else {\n\tfv.Mode = av.NewItemFieldValueStatic\n}","handlingStrategy":"validation","validationCode":"key, err := av.GetKey(keyID)\nif err == nil && fv.Mode == av.NewItemFieldValueCurrentTime && key.Type != av.KeyTypeDate {\n\tfv.Mode = av.NewItemFieldValueStatic\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only offer the current-time mode in UIs when the target field is a date field","Reset the mode to static whenever a field's type changes away from date"],"tags":["attribute-view","validation","type-mismatch"],"backgroundTag":"invalid-config-value","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}