func (self SetModelValueControllerBase) SetValue(value string, ctx *Context, metaData *model.MetaData, form *Form) error { mdl, ok := metaData.ModelValue() if !ok { panic("metaData must be model.Value") } mdl.SetString(value) return nil }
func (self *Form) IsFieldRequired(metaData *model.MetaData) bool { if val, ok := metaData.ModelValue(); ok && val.Required(metaData) { return true } selector := metaData.Selector() wildcardSelector := metaData.WildcardSelector() return utils.StringIn(selector, self.RequiredFields) || utils.StringIn(wildcardSelector, self.RequiredFields) }
func (self *validateAndFormLayoutStructVisitor) validateField(field *model.MetaData) error { if value, ok := field.ModelValue(); ok { err := value.Validate(field) if err == nil && value.IsEmpty() && self.form.IsFieldRequired(field) { err = model.NewRequiredError(field) } if err != nil { self.fieldValidationErrors = append(self.fieldValidationErrors, err) } return err } return nil }
func (self *Form) IsFieldRequired(field *model.MetaData) bool { if val, ok := field.ModelValue(); ok && val.Required(field) { return true } return field.SelectorsMatch(self.RequiredFields) }