ENUM

HaapiModel.FormFieldFactory

Contents

enum FormFieldFactory

Provides functionality to build instances of FormField.

Methods

selectOption(label:value:selected:)

public static func selectOption(label: Message,
                                value: String,
                                selected: Bool) -> SelectFormField.Option

Creates an instance of SelectFormField.Option model.

Parameters

Name Description
label A label that describes the field.
value The value representation for the option.
selected The selection state of the field.

select(options:name:label:required:)

public static func select(options: [SelectFormField.Option],
                          name: String,
                          label: Message?,
                          required: Bool = true) -> SelectFormField

Creates an instance of SelectFormField model.

Parameters

Name Description
options An array of SelectFormField.Option that represents the available options to choose from.
name The field name identifier.
label A label that describes the field.
isRequired A bool value that indicates if the field is mandatory. Default is true.

checkbox(checked:readonly:name:value:label:isRequired:)

public static func checkbox(checked: Bool,
                            readonly: Bool,
                            name: String,
                            value: String?,
                            label: Message?,
                            isRequired: Bool = true) -> CheckboxFormField

Creates an instance of CheckboxFormField model.

Parameters

Name Description
checked The current check state of the Checkbox field.
readonly A bool value that dictates if the checkedvalue is mutable.
name The field name identifier.
value The representation of the value for the field.
label A label that describes the field.
isRequired A bool value that indicates if the field is mandatory. Default is true.

password(name:value:label:placeholder:maxLength:minLength:isRequired:)

public static func password(name: String,
                            value: String?,
                            label: Message?,
                            placeholder: Message?,
                            maxLength: Int? = nil,
                            minLength: Int? = nil,
                            isRequired: Bool = true) -> PasswordFormField

Creates an instance of PasswordFormField model.

Parameters

Name Description
name The field name identifier.
value The field’s current value.
label A label that describes the field.
placeholder A label that describes a possible hint for the field.
maxLength Maximum number of characters the field value must contain. Default is nil.
minLength Minimum number of characters the field value must contain. Default is nil.
isRequired A bool value that indicates if the field is mandatory. Default is true.

username(name:value:label:placeholder:maxLength:minLength:isRequired:)

public static func username(name: String,
                            value: String?,
                            label: Message?,
                            placeholder: Message?,
                            maxLength: Int? = nil,
                            minLength: Int? = nil,
                            isRequired: Bool = true) -> UsernameFormField

Creates an instance of UsernameFormField model.

Parameters

Name Description
name The field name identifier.
value The field’s current value.
label A label that describes the field.
placeholder A label that describes a possible hint for the field.
maxLength Maximum number of characters the field value must contain. Default is nil.
minLength Minimum number of characters the field value must contain. Default is nil.
isRequired A bool value that indicates if the field is mandatory. Default is true.

text(kind:name:value:label:placeholder:maxLength:minLength:isRequired:)

public static func text(kind: TextFormField.Kind?,
                        name: String,
                        value: String?,
                        label: Message?,
                        placeholder: Message?,
                        maxLength: Int? = nil,
                        minLength: Int? = nil,
                        isRequired: Bool = true) -> TextFormField

Creates an instance of TextFormField model.

Parameters

Name Description
kind The TextFormField.Kind value for the represented field.
name The field name identifier.
value The field’s current value.
label A label that describes the field.
placeholder A label that describes a possible hint for the field.
maxLength The maximum number of characters allowed in the field.
minLength The minimum number of characters required in the field.
isRequired A bool value that indicates if the field is mandatory. Default is true.

context(name:isRequired:)

public static func context(name: String, isRequired: Bool = true) -> ContextFormField

Creates an instance of ContextFormField model.

Parameters

Name Description
name The field name identifier.
isRequired A bool value that indicates if the field is mandatory. Default is true.

hidden(name:value:isRequired:)

public static func hidden(name: String, value: String, isRequired: Bool = true) -> HiddenFormField

Creates an instance of HiddenFormField model.

Parameters

Name Description
name The field name identifier.
value The representation of the value for the field.
isRequired A bool value that indicates if the field is mandatory. Default is true.