From d61e0a214e394e66ad8cfdbdec6caddedd1d10f9 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 2 Jan 2017 10:27:44 -0800 Subject: add reference.SelectRepeater and necessary struct and function exports --- .../ponzu-cms/addons/reference/reference.go | 106 ++++++++++++++++++++- 1 file changed, 101 insertions(+), 5 deletions(-) (limited to 'addons') diff --git a/addons/github.com/ponzu-cms/addons/reference/reference.go b/addons/github.com/ponzu-cms/addons/reference/reference.go index f90964c..9918f36 100644 --- a/addons/github.com/ponzu-cms/addons/reference/reference.go +++ b/addons/github.com/ponzu-cms/addons/reference/reference.go @@ -9,6 +9,7 @@ import ( "fmt" "html/template" "log" + "strings" "github.com/ponzu-cms/ponzu/management/editor" "github.com/ponzu-cms/ponzu/system/addon" @@ -19,7 +20,101 @@ import ( // 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 Select(fieldName string, p interface{}, attrs map[string]string, contentType, tmplString string) []byte { - // decode all content type from db into options map + options, err := encodeDataToOptions(contentType, tmplString) + if err != nil { + log.Println("Error encoding data to options for", contentType, err) + return nil + } + + return editor.Select(fieldName, p, attrs, options) +} + +// SelectRepeater returns the []byte of a