RSDInputFieldObject

open class RSDInputFieldObject : RSDSurveyInputField, RSDMutableInputField, RSDCopyInputField, Codable

RSDInputFieldObject is a Decodable implementation of the RSDSurveyInputField protocol. This is implemented as an open class so that the decoding strategy can be used to support subclasses.

  • A short string that uniquely identifies the input field within the step. The identifier is reproduced in the results of a step result in the step history of a task result.

    Declaration

    Swift

    public let identifier: String
  • The data type for this input field. The data type can have an associated ui hint.

    Declaration

    Swift

    open private(set) var dataType: RSDFormDataType {
      get
      }
  • A UI hint for how the study would prefer that the input field is displayed to the user.

    Declaration

    Swift

    open private(set) var inputUIHint: RSDFormUIHint? {
      get
      }
  • A localized string that displays a short text offering a hint to the user of the data to be entered for this field. This is only applicable for certain types of UI hints and data types.

    Declaration

    Swift

    open var inputPrompt: String?
  • Additional detail about this input field.

    Declaration

    Swift

    open var inputPromptDetail: String?
  • A localized string that displays placeholder information for the input field.

    You can display placeholder text in a text field or text area to help users understand how to answer the item’s question.

    Declaration

    Swift

    open var placeholder: String?
  • Options for displaying a text field. This is only applicable for certain types of UI hints and data types.

    Declaration

    Swift

    open var textFieldOptions: RSDTextFieldOptions?
  • A range used by dates and numbers for setting up a picker wheel, slider, or providing text field input validation. This is only applicable for certain types of UI hints and data types.

    Declaration

    Swift

    open var range: RSDRange?
  • A Boolean value indicating whether the user can skip the input field without providing an answer.

    Declaration

    Swift

    open var isOptional: Bool
  • A list of survey rules associated with this input field.

    Declaration

    Swift

    open var surveyRules: [RSDSurveyRule]?
  • A formatter that is appropriate to the data type. If nil, the format will be determined by the UI. This is the formatter used to display a previously entered answer to the user or to convert an answer entered in a text field into the appropriate value type.

    Seealso

    RSDAnswerResultType.BaseType and RSDFormStepDataSource

    Declaration

    Swift

    open var formatter: Formatter? { get set }
  • Default for the picker source is to optionally cast self.

    Declaration

    Swift

    open var pickerSource: RSDPickerDataSource? { get }
  • Default intializer.

    Declaration

    Swift

    public init(identifier: String, dataType: RSDFormDataType, uiHint: RSDFormUIHint? = nil, prompt: String? = nil)

    Parameters

    identifier

    A short string that uniquely identifies the input field within the step.

    dataType

    The data type for this input field.

    uiHint

    A UI hint for how the study would prefer that the input field is displayed to the user.

    prompt

    A localized string that displays a short text offering a hint to the user of the data to be entered for this field.

  • Declaration

    Swift

    public func copy(with identifier: String) -> Self
  • Swift subclass override for copying properties from the instantiated class of the copy(with:) method. Swift does not nicely handle casting from Self to a class instance for non-final classes. This is a work-around.

    Declaration

    Swift

    open func copyInto(_ copy: RSDInputFieldObject)
  • Validate the input field to check for any configuration that should throw an error.

    Declaration

    Swift

    open func validate() throws
  • Class function for decoding the data type from the decoder. The default implementation will key to CodingKeys.dataType.

    Throws

    DecodingError if the data type field is missing or is not a String.

    Declaration

    Swift

    public final class func dataType(from decoder: Decoder) throws -> RSDFormDataType

    Parameters

    decoder

    The decoder used to decode this object.

    Return Value

    The decoded RSDFormDataType data type.

  • Overridable class function for decoding the RSDTextFieldOptions from the decoder. The default implementation will key to CodingKeys.textFieldOptions. If no text field options are defined in the decoder, then for certain data types, the default keyboard type is instantiated.

    If the data type has a BaseType of an integer, an instance of RSDTextFieldOptionsObject will be created with a numberPad keyboard type.

    If the data type has a BaseType of a decimal, an instance of RSDTextFieldOptionsObject will be created with a decimalPad keyboard type.

    Throws

    DecodingError

    Declaration

    Swift

    open class func textFieldOptions(from decoder: Decoder, dataType: RSDFormDataType) throws -> RSDTextFieldOptions?

    Parameters

    decoder

    The decoder used to decode this object.

    dataType

    The data type associated with this instance.

    Return Value

    An appropriate instance of RSDTextFieldOptions or nil if none is present.

  • Initialize from a Decoder. This decoding method will decode all the properties for this input field.

    Throws

    DecodingError

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    decoder

    The decoder to use to decode this instance.

  • Encode the object to the given encoder.

    Throws

    EncodingError

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    encoder

    The encoder to use to encode this instance.