diff options
author | Steve <nilslice@gmail.com> | 2016-10-17 21:31:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-17 21:31:59 -0700 |
commit | 2f3985491363dc0658ad8cf3a415a77c1825a67a (patch) | |
tree | fa398a23c9e247e9cc7515898f0f6ddabf392f64 /management/editor/elements.go | |
parent | 9c8ed5c6a88901bf139bf9bb7b884b222c6053ce (diff) | |
parent | 30b47784c5889539a65cc292066a400aa19c35d0 (diff) |
Merge pull request #2 from bosssauce/ponzu-dev
[core] move content.Item to unix-y Timestamp and Updated fields
Diffstat (limited to 'management/editor/elements.go')
-rw-r--r-- | management/editor/elements.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/management/editor/elements.go b/management/editor/elements.go index e8a2fab..390d8df 100644 --- a/management/editor/elements.go +++ b/management/editor/elements.go @@ -37,6 +37,31 @@ func Textarea(fieldName string, p interface{}, attrs map[string]string) []byte { return domElement(e) } +// Timestamp returns the []byte of an <input> HTML element with a label. +// IMPORTANT: +// The `fieldName` argument will cause a panic if it is not exactly the string +// form of the struct field that this editor input is representing +func Timestamp(fieldName string, p interface{}, attrs map[string]string) []byte { + var data string + val := valueFromStructField(fieldName, p) + if val.Int() == 0 { + data = "" + } else { + data = fmt.Sprintf("%d", val.Int()) + } + + e := &element{ + TagName: "input", + Attrs: attrs, + Name: tagNameFromStructField(fieldName, p), + label: attrs["label"], + data: data, + viewBuf: &bytes.Buffer{}, + } + + return domElementSelfClose(e) +} + // File returns the []byte of a <input type="file"> HTML element with a label. // IMPORTANT: // The `fieldName` argument will cause a panic if it is not exactly the string |