summaryrefslogtreecommitdiff
path: root/management/editor/values.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-01-02 10:27:44 -0800
committerSteve Manuel <nilslice@gmail.com>2017-01-02 10:27:44 -0800
commitd61e0a214e394e66ad8cfdbdec6caddedd1d10f9 (patch)
treeb162bf6119815470c6a2e213cda9c4be89c397ea /management/editor/values.go
parentca002d0f447f0e9d7a71cd502a20b63277a612ce (diff)
add reference.SelectRepeater and necessary struct and function exports
Diffstat (limited to 'management/editor/values.go')
-rw-r--r--management/editor/values.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/management/editor/values.go b/management/editor/values.go
index 7d71d3f..bc97f99 100644
--- a/management/editor/values.go
+++ b/management/editor/values.go
@@ -6,7 +6,9 @@ import (
"strings"
)
-func tagNameFromStructField(name string, post interface{}) string {
+// TagNameFromStructField does a lookup on the `json` struct tag for a given
+// field of a struct
+func TagNameFromStructField(name string, post interface{}) string {
// sometimes elements in these environments will not have a name,
// and thus no tag name in the struct which correlates to it.
if name == "" {
@@ -26,16 +28,19 @@ func tagNameFromStructField(name string, post interface{}) string {
return tag
}
+// TagNameFromStructFieldMulti calls TagNameFromStructField and formats is for
+// use with gorilla/schema
// due to the format in which gorilla/schema expects form names to be when
// one is associated with multiple values, we need to output the name as such.
// Ex. 'category.0', 'category.1', 'category.2' and so on.
-func tagNameFromStructFieldMulti(name string, i int, post interface{}) string {
- tag := tagNameFromStructField(name, post)
+func TagNameFromStructFieldMulti(name string, i int, post interface{}) string {
+ tag := TagNameFromStructField(name, post)
return fmt.Sprintf("%s.%d", tag, i)
}
-func valueFromStructField(name string, post interface{}) string {
+// ValueFromStructField returns the string value of a field in a struct
+func ValueFromStructField(name string, post interface{}) string {
field := reflect.Indirect(reflect.ValueOf(post)).FieldByName(name)
switch field.Kind() {