ENUM
HaapiModel.FormFieldFactory
Contents
- Methods
selectOption(label:value:selected:)select(options:name:label:required:)checkbox(checked:readonly:name:value:label:isRequired:)password(name:value:label:placeholder:maxLength:minLength:isRequired:)username(name:value:label:placeholder:maxLength:minLength:isRequired:)text(kind:name:value:label:placeholder:maxLength:minLength:isRequired:)context(name:isRequired:)hidden(name:value:isRequired:)
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:
- label: A label that describes the field.
- value: The value representation for the option.
- selected: The selection state of the field.
-
Returns: A built instance of
SelectFormField.Option.
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:
- options: An array of
SelectFormField.Optionthat 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.
- options: An array of
-
Returns: A built instance of
SelectFormField.
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:
- checked: The current
checkstate of theCheckboxfield. - 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.
- checked: The current
-
Returns: A built instance of
CheckboxFormField.
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: 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.
-
Returns: A built instance of
PasswordFormField.
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: 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.
-
Returns: A built instance of
UsernameFormField.
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:
- kind: The
TextFormField.Kindvalue 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.
- kind: The
-
Returns: A built instance of
TextFormField.
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: The field name identifier.
- isRequired: A bool value that indicates if the field is mandatory. Default is
true.
-
Returns: A built instance of
ContextFormField.
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: 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.
-
Returns: A built instance of
HiddenFormField.
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. |