Support for embedded fields in editform
This commit is contained in:
parent
0fc613011f
commit
e8f59bf0e6
@ -96,14 +96,21 @@ func RenderObject(b *bytes.Buffer, obj interface{}, idPrefix string) {
|
|||||||
|
|
||||||
// RenderField ...
|
// RenderField ...
|
||||||
func RenderField(b *bytes.Buffer, v *reflect.Value, field reflect.StructField, idPrefix string) {
|
func RenderField(b *bytes.Buffer, v *reflect.Value, field reflect.StructField, idPrefix string) {
|
||||||
if field.Anonymous || field.Tag.Get("editable") != "true" {
|
fieldValue := reflect.Indirect(v.FieldByName(field.Name))
|
||||||
|
|
||||||
|
// Embedded fields
|
||||||
|
if field.Anonymous {
|
||||||
|
RenderObject(b, fieldValue.Interface(), idPrefix)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if field.Tag.Get("editable") != "true" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
b.WriteString("<div class='mountable'>")
|
b.WriteString("<div class='mountable'>")
|
||||||
defer b.WriteString("</div>")
|
defer b.WriteString("</div>")
|
||||||
|
|
||||||
fieldValue := reflect.Indirect(v.FieldByName(field.Name))
|
|
||||||
fieldType := field.Type.String()
|
fieldType := field.Type.String()
|
||||||
|
|
||||||
// String
|
// String
|
||||||
|
Loading…
Reference in New Issue
Block a user