Support for embedded fields in editform

This commit is contained in:
Eduard Urbach 2018-04-03 13:56:35 +02:00
parent 0fc613011f
commit e8f59bf0e6

View File

@ -96,14 +96,21 @@ func RenderObject(b *bytes.Buffer, obj interface{}, idPrefix string) {
// RenderField ...
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
}
b.WriteString("<div class='mountable'>")
defer b.WriteString("</div>")
fieldValue := reflect.Indirect(v.FieldByName(field.Name))
fieldType := field.Type.String()
// String