// FieldLabel returns a label for a form field generated from metaData. // It creates the label from the names or label tags of metaData and // all its parents, starting with the root parent, concanated with a space // character. func (self *Form) FieldLabel(metaData *model.MetaData) string { selector := metaData.Selector() if label, ok := self.Labels[selector]; ok { return label } wildcardSelector := metaData.WildcardSelector() if label, ok := self.Labels[wildcardSelector]; ok { return label } var buf bytes.Buffer for _, m := range metaData.Path()[1:] { if buf.Len() > 0 { buf.WriteByte(' ') } buf.WriteString(self.DirectFieldLabel(m)) } return buf.String() }