classafFormBean::FormField
sys::Obj afFormBean::FormField
Holds all the meta data required to convert a field on a Fantom object to HTML and back again.
- attributes
Str? attributesHTML attribute. Any other miscellaneous attributes that should be rendered on the
<input>. Example:attributes = "autocomplete='off'"
- blankLabel
Str? blankLabelUsed by the
<select>renderer. This is the label to display in the blank option.leave as null to use
OptionsProvider.blankLabelvalue.- css
Str? cssHTML attribute. The value to render as a CSS
classattribute on the<input>.- doHtmlValidation
virtual Void doHtmlValidation()Performs basic HTML5 validation.
- errMsg
Str? errMsgThe error message associated with this field.
Setting this to a non-null value invalidate the form field.
- field
Field fieldThe Fantom field this
FormFieldrepresents.- formBean
FormBean formBeanA link back to the owning
FormBeaninstance.- formData
Obj? formDataUsed as temporary store when uploading binary data, such as
BufsandFiles. Contains the value that the form field will be set to.- formValue
Str? formValueThe
Strvalue that will be rendered in the HTML form. You may set this value before the form is rendered to set a default value.If the
formValueisnullthen the field value is used instead and converted byvalueEncoder.This
formValueis also set during form validation so any user entered values are re-rendered should the form be re-displayed.- hint
Str? hintIf non-null an extra
<div>is rendered after the<input>to supply a helpful hint. The hint is usually rendered with theformBean-hintCSS class.- inputSkin
InputSkin? inputSkinThe
InputSkinused to render the field to HTML.If
nullthen a defaultInputSkinis chosen based on thetypeattribute.- invalid
Bool invalidIs this form field invalid?
Setting this to
falsealso clears anyerrMsg.- label
Str? labelThe label to display next to the
<input>.If
nullthen it defaults to a human readable version of the field name.- max
Int? maxHTML5 validation attribute. Sets the maximum value (inclusive) an
Intshould have.- maxLength
Int? maxLengthHTML5 validation attribute. Sets the maximum length (inclusive) a string should be.
- min
Int? minHTML5 validation attribute. Sets the minimum value (inclusive) an
Intshould have.- minLength
Int? minLengthHTML5 validation attribute. Sets the minimum length (inclusive) a string should be.
- msg
Str? msg(Str key, Obj? arg1 := null, Obj? arg2 := null, Obj? arg3 := null)Returns a message for the given field. Messages are looked up in the following order:
<bean>.<field>.<key><field>.<key><key>
And the following substitutions are made:
${label} -> formField.label${value} -> formField.formValue${arg1} -> arg1.toStr${arg2} -> arg2.toStr${arg3} -> arg3.toStr
The form value is substituted for
${value}because it is intended for use by validation msgs.Returns
nullif a msg could not be found.- optionsProvider
OptionsProvider? optionsProviderUsed by the
<select>renderer. TheOptionsProviderused to supply option values when rendering<select>tags.If
nullthen a defaultOptionsProvideris chosen based on the field type.- pattern
Regex? patternHTML5 validation attribute. Sets a regular expression that the (stringified) value should match. Starting
^and ending$characters are implicit and not required.- placeholder
Str? placeholderHTML attribute. The value to render as a
placeholderattribute on the<input>.- render
Hook to render this field to HTML. By default this defers rendering to an
InputSkin.Override to perform custom field rendering.
- required
Bool? requiredHTML5 validation attribute. Set to
trueto mark the input as required. Ifnull(the default) then the input is required if the field is non-nullable.- showBlank
Bool? showBlankUsed by the
<select>renderer. Set totrueto show a blank value at the start of the options list.leave as null to use
OptionsProvider.showBlankvalue.- step
Int? stepHTML5 validation attribute. Defines the interval for a numeric input.
- type
Str? typeHTML attribute. The type of input to render.
If
nullthen it defaults totext.- validate
virtual Void validate()Validates this form field. Calls
doHtmlValidation()and then any static@Validatemethod that corresponds to this field.@Validatemethods may checkinvalidanderrMsgto ascertain if any previous validation failed.- valueEncoder
ValueEncoder? valueEncoderThe
ValueEncoderused to convert the field value to and from aStr.If
nullthen a defaultValueEncoderbased on the field type is chosen from BedSheet'sValueEncodersservice.- viewOnly
Bool? viewOnlyIf
truethen the field is rendered into the HTML form as normal, but no attempt is made to validate the form value or decode it back to a Fantom value.Useful for rendering static, read only, HTML associated with the field.