예제 #1
0
파일: form.go 프로젝트: roleyzhang/go-start
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 indexedFields
	if indexedFields.Kind == model.SliceKind && !self.isPost && indexedFields.Value.CanSet() {
		indexedFields.Value.Set(reflection.DeleteDefaultSliceElementsVal(indexedFields.Value))
		indexedFields.Value.Set(reflection.AppendDefaultSliceElement(indexedFields.Value))
		mongo.InitRefs(self.formModel)
	}
	return self.formLayout.BeginIndexedFields(indexedFields, self.form, self.ctx, self.formContent)
}
예제 #2
0
파일: form.go 프로젝트: roleyzhang/go-start
func (self *setPostValuesStructVisitor) EndIndexedFields(indexedFields *model.MetaData) error {
	if indexedFields.Kind == model.SliceKind && indexedFields.Value.CanSet() && !self.form.IsFieldExcluded(indexedFields, self.ctx) {
		indexedFields.Value.Set(reflection.DeleteDefaultSliceElementsVal(indexedFields.Value))
	}
	return nil
}