Beispiel #1
0
func makeFields(oItemDef itemDef.ItemDef, names []string) itemDef.ItemDef {
	fields := make([]itemDef.Field, len(names))

	fieldMap := oItemDef.GetFieldMap()
	for idx, name := range names {
		if field, ok := fieldMap[name]; ok {
			fields[idx] = field
		} else {
			beego.Error("Field not found", name, idx)
		}
	}
	oItemDef.Fields = fields
	return oItemDef
}
Beispiel #2
0
func extendUserField(oItemDef itemDef.ItemDef, fieldName string) itemDef.ItemDef {
	userField, _ := oItemDef.GetField(fieldName)
	userField.Name = fieldName + s.Name
	userSnField, _ := oItemDef.GetField(fieldName)
	userSnField.Input = s.Hidden
	newFields := make([]itemDef.Field, 0)
	for _, field := range oItemDef.Fields {
		if field.Name == fieldName {
			newFields = append(newFields, userField)
			newFields = append(newFields, userSnField)
		} else {
			newFields = append(newFields, field)
		}
	}
	oItemDef.Fields = newFields
	return oItemDef
}