Example #1
0
func (self *validateAndFormLayoutStructVisitor) BeginSlice(slice *model.MetaData) error {
	if slice.Parent == nil {
		err := self.formLayout.BeginFormContent(self.form, self.context, self.formContent)
		if err != nil {
			return err
		}
	}
	// Add an empty slice field to generate one extra input row for slices
	if !self.isPost && slice.Value.CanSet() && !self.form.IsFieldExcluded(slice) {
		slice.Value.Set(utils.AppendEmptySliceField(slice.Value))
		mongo.InitRefs(self.formModel)
	}
	return self.formLayout.BeginSlice(slice, self.form, self.context, self.formContent)
}
Example #2
0
func (self *validateAndFormLayoutStructVisitor) BeginIndexedFields(indexedFields *model.MetaData) error {
	if indexedFields.Parent == nil {
		err := self.formLayout.BeginFormContent(self.form, self.ctx, self.formContent)
		if err != nil {
			return err
		}
	}
	if self.form.IsFieldExcluded(indexedFields, self.ctx) {
		return nil
	}
	// Add an empty indexedFields field to generate one extra input row for indexedFieldss
	if indexedFields.Kind == model.SliceKind && !self.isPost && indexedFields.Value.CanSet() {
		indexedFields.Value.Set(utils.AppendEmptySliceField(indexedFields.Value))
		mongo.InitRefs(self.formModel)
	}
	return self.formLayout.BeginIndexedFields(indexedFields, self.form, self.ctx, self.formContent)
}