func (self ModelStringController) NewInput(withLabel bool, metaData *model.MetaData, form *Form) (input View, err error) { str := metaData.Value.Addr().Interface().(*model.String) textField := &TextField{ Class: form.FieldInputClass(metaData), Name: metaData.Selector(), Text: str.Get(), Size: form.GetInputSize(metaData), Disabled: form.IsFieldDisabled(metaData), Placeholder: form.InputFieldPlaceholder(metaData), Required: form.IsFieldRequired(metaData) && !metaData.IsSelfOrParentIndexed(), Title: form.FieldLabel(metaData), } if maxlen, ok, _ := str.Maxlen(metaData); ok { textField.MaxLength = maxlen if maxlen < textField.Size { textField.Size = maxlen } } if metaData.BoolAttrib("view", "search") { textField.Type = SearchTextField } if metaData.BoolAttrib("view", "autofocus") { textField.Autofocus = true } if pattern, ok := metaData.Attrib("view", "pattern"); ok { textField.Pattern = pattern } if withLabel { return AddStandardLabel(form, textField, metaData), nil } return textField, nil }
func (self ModelIntController) NewInput(withLabel bool, metaData *model.MetaData, form *Form) (input View, err error) { i := metaData.Value.Addr().Interface().(*model.Int) textField := &TextField{ Class: form.FieldInputClass(metaData), Name: metaData.Selector(), Text: i.String(), Disabled: form.IsFieldDisabled(metaData), Placeholder: form.InputFieldPlaceholder(metaData), Required: form.IsFieldRequired(metaData) && !metaData.IsSelfOrParentIndexed(), Title: form.FieldLabel(metaData), } if metaData.BoolAttrib("view", "autofocus") { textField.Autofocus = true } if withLabel { return AddStandardLabel(form, textField, metaData), nil } return textField, nil }
func (self ModelDateTimeController) NewInput(withLabel bool, metaData *model.MetaData, form *Form) (input View, err error) { dateTime := metaData.Value.Addr().Interface().(*model.DateTime) input = Views{ HTML("(Format: " + model.DateTimeFormat + ")<br/>"), &TextField{ Class: form.FieldInputClass(metaData), Name: metaData.Selector(), Text: dateTime.Get(), Size: len(model.DateTimeFormat), Disabled: form.IsFieldDisabled(metaData), Placeholder: form.InputFieldPlaceholder(metaData), Required: form.IsFieldRequired(metaData) && !metaData.IsSelfOrParentIndexed(), Title: form.FieldLabel(metaData), }, } if withLabel { return AddStandardLabel(form, input, metaData), nil } return input, nil }
func (self ModelUrlController) NewInput(withLabel bool, metaData *model.MetaData, form *Form) (View, error) { url := metaData.Value.Addr().Interface().(*model.Url) input := &TextField{ Class: form.FieldInputClass(metaData), Name: metaData.Selector(), Text: url.Get(), Size: form.GetInputSize(metaData), Disabled: form.IsFieldDisabled(metaData), Placeholder: form.InputFieldPlaceholder(metaData), Required: form.IsFieldRequired(metaData) && !metaData.IsSelfOrParentIndexed(), Title: form.FieldLabel(metaData), } if metaData.BoolAttrib("view", "autofocus") { input.Autofocus = true } if withLabel { return AddStandardLabel(form, input, metaData), nil } return input, nil }