Inherits from UIView
Conforms to SFormInputElementResponder
Declared in SFormFieldView.h
Availability
Related samples

Overview

A view for data entry.

SFormField is composed of the following subviews: - label: Synchronises to the title of its model. - requiredLabel: Is shown or hidden depending on the required value of its model. - inputElement: Synchronises to the value of it’s model - errorLabel: Synchronises to the invalidMessage first failing validator of the model’s currentlyFailingValidators array.

Field can make use of different layouts - see layout.

Available SFormFieldView subclasses are as follows: - SFormTextFieldView. - SFormSegmentedFieldView. - SFormDateFieldView. - SFormSliderFieldView. - SFormPickerFieldView. - SFormSwitchFieldView.

Tasks

Other Methods

  •   model

    The model being presented.

    property

Converting Values Between Model and View

  •   converter

    The converter used to ensure the correct format and object types are used when values are passed from model to this view and vice versa.

    property

Appearance

Default Appearance

Valid Appearance

Invalid Appearance

Disabled Appearance

Focused Appearance

Syncing Views and Models

Properties

converter

The converter used to ensure the correct format and object types are used when values are passed from model to this view and vice versa.

@property (nonatomic, strong) id<SFormFieldModelViewConverter> converter

Declared In

SFormFieldView.h

defaultErrorLabelFont

The font that is applied to errorLabel when this field view enters its default state.

@property (nonatomic, strong) UIFont *defaultErrorLabelFont

Declared In

SFormFieldView.h

defaultErrorLabelTextColor

The text color that is applied to errorLabel when this field view enters its default state.

@property (nonatomic, strong) UIColor *defaultErrorLabelTextColor

Declared In

SFormFieldView.h

defaultInputElementBackgroundColor

The background color that is applied to inputElement when this field view enters its default state.

@property (nonatomic, strong) UIColor *defaultInputElementBackgroundColor

Declared In

SFormFieldView.h

defaultInputElementBorderColor

The border color that is applied to inputElement when this field view enters its default state.

@property (nonatomic, strong) UIColor *defaultInputElementBorderColor

Declared In

SFormFieldView.h

defaultInputElementBorderWidth

The border width that is applied to inputElement when this field view enters its default state.

@property (nonatomic, assign) CGFloat defaultInputElementBorderWidth

Declared In

SFormFieldView.h

defaultInputElementCornerRadius

The corner radius that is applied to inputElement when this field view enters its default state.

@property (nonatomic, assign) CGFloat defaultInputElementCornerRadius

Declared In

SFormFieldView.h

defaultInputElementTintColor

The tint color that is applied to inputElement when this field view enters its default state.

@property (nonatomic, strong) UIColor *defaultInputElementTintColor

Declared In

SFormFieldView.h

defaultLabelFont

The font that is applied to label when this field view enters its default state.

@property (nonatomic, strong) UIFont *defaultLabelFont

Declared In

SFormFieldView.h

defaultLabelTextColor

The text color that is applied to label when this field view enters its default state.

@property (nonatomic, strong) UIColor *defaultLabelTextColor

Declared In

SFormFieldView.h

defaultRequiredLabelFont

The font that is applied to requiredLabel when this field view enters its default state.

@property (nonatomic, strong) UIFont *defaultRequiredLabelFont

Declared In

SFormFieldView.h

defaultRequiredLabelTextColor

The text color that is applied to requiredLabel when this field view enters its default state.

@property (nonatomic, strong) UIColor *defaultRequiredLabelTextColor

Declared In

SFormFieldView.h

disabledInputElementBackgroundColor

The background color that is applied to inputElement when this field view enters its disabled state.

@property (nonatomic, strong) UIColor *disabledInputElementBackgroundColor

Declared In

SFormFieldView.h

enabled

Whether this view is enabled for input entry.

@property (nonatomic, assign, getter=isEnabled) BOOL enabled

Discussion

Setting this to NO will change the field to look inactive, giving it a faded appearance.

Defaults to YES.

Declared In

SFormFieldView.h

errorLabel

A label showing validation error messages.

@property (nonatomic, strong) UILabel *errorLabel

Discussion

This label displays the error message provided by the model’s first failing validator.

Declared In

SFormFieldView.h

focusedInputElementBorderColor

The border color that is applied to inputElement when this field view enters its focused state.

@property (nonatomic, strong) UIColor *focusedInputElementBorderColor

Declared In

SFormFieldView.h

inputElement

The view used for data entry.

@property (nonatomic, strong) UIView *inputElement

Discussion

This view is kept in sync with the model’s value property. The type of the value in the input element can differ from the type of the value on the model - the conversion is handled by the field’s converter.

Declared In

SFormFieldView.h

invalidInputElementBorderColor

The border color that is applied to inputElement when this field view enters its invalid state.

@property (nonatomic, strong) UIColor *invalidInputElementBorderColor

Declared In

SFormFieldView.h

invalidInputElementBorderWidth

The border width that is applied to inputElement when this field view enters its invalid state.

@property (nonatomic, assign) CGFloat invalidInputElementBorderWidth

Declared In

SFormFieldView.h

label

The field’s title label.

@property (nonatomic, strong) UILabel *label

Discussion

This label’s text value is kept in sync with the model’s title.

Declared In

SFormFieldView.h

layout

The layout object used by this field.

@property (nonatomic, strong) id<SFormFieldLayout> layout

Discussion

This layout object is delegated to when the field lays out (layoutSubviews) and is auto-sized (when calling sizeToFit). Setting this layout object allows you to change the layout of a field without subclassing.

The available layouts: - SFormFieldLayoutLabelOnTopOfInput: The label is positioned above the input element (default). - SFormFieldLayoutLabelLeftOfInput: The label is positioned to the left of the input element. - SFormFieldLayoutNoLabel: The label will be hidden.

To take manual control of layout you can nil out this object:

      fieldView.layout = nil

Default is SFormFieldLayoutLabelOnTopOfInput.

Declared In

SFormFieldView.h

model

The model being presented.

@property (nonatomic, strong) SFormField *model

Declared In

SFormFieldView.h

validInputElementBorderColor

The border color that is applied to inputElement when this field view enters its valid state.

@property (nonatomic, strong) UIColor *validInputElementBorderColor

Declared In

SFormFieldView.h

validInputElementBorderWidth

The border width that is applied to inputElement when this field view enters its valid state.

@property (nonatomic, assign) CGFloat validInputElementBorderWidth

Declared In

SFormFieldView.h

Class Methods

defaultLayout

The default layout used the field when a layout isn’t provided.

+ (id<SFormFieldLayout>)defaultLayout

Declared In

SFormFieldView.h

Instance Methods

updateAsDefault

Style the field in it’s default look.

- (void)updateAsDefault

Declared In

SFormFieldView.h

updateAsDisabled

Style the field in it’s disabled look.

- (void)updateAsDisabled

Declared In

SFormFieldView.h

updateAsFocused

Style the field in it’s focused look.

- (void)updateAsFocused

Declared In

SFormFieldView.h

updateAsInvalid

Style the field in it’s invalid look.

- (void)updateAsInvalid

Declared In

SFormFieldView.h

updateAsValid

Style the field in it’s valid look.

- (void)updateAsValid

Declared In

SFormFieldView.h

updateInputElementFromInputView

Updates inputElement’s displayed value to match that of its inputView’s current state.

- (void)updateInputElementFromInputView

Discussion

Note that the inputView has to be capabable of persistent state in order for this method to do anything useful.

It is unusual to need to call this method directly. However it might be useful for subclassing/overridding in order to modify how this field view updates its inputElement from the associated inputView.

Declared In

SFormFieldView.h

updateModel

Updates model with the current contents of this view.

- (void)updateModel

Discussion

Subclasses will typically implement this by pulling needed values from the inputElement or the inputElement’s inputView, doing any necessary formatting, and then setting this on the model’s value.

It is unusual to need to call this method directly, as any user input into this field view automatically triggers this method. However it might be useful for subclassing/overridding in order to modify how this field view updates its model.

Declared In

SFormFieldView.h