RSDChoiceInputFieldObject

open class RSDChoiceInputFieldObject : RSDInputFieldObject, RSDChoiceOptionsWithDefault

RSDChoiceInputFieldObject is a concrete implementation of RSDChoiceInputField that subclasses RSDInputFieldObject to include a list of choices for a multiple choice or single choice input field. It is intended to be instantiated with a list of choices but can be subclassed to decode the choices using a custom decoder.

  • A list of choices for the input field.

    Declaration

    Swift

    public private(set) var choices: [RSDChoice] {
      get
      }
  • The default answer associated with this option set.

    Declaration

    Swift

    open private(set) var defaultAnswer: Any? {
      get
      }
  • Override isOptional to allow for nil behavior if there is only one choice. Otherwise, there isn’t really a way for the user to not select that choice.

    Declaration

    Swift

    override open var isOptional: Bool { get set }
  • Default initializer.

    Declaration

    Swift

    public init(identifier: String, choices: [RSDChoice], dataType: RSDFormDataType, uiHint: RSDFormUIHint? = nil, prompt: String? = nil, defaultAnswer: Any? = nil)

    Parameters

    identifier

    A short string that uniquely identifies the form item within the step.

    choices

    A list of choices for the input field.

    dataType

    The data type for this input field. The data type can have an associated ui hint.

    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.

  • This is a required initializer for copying, but the choices will be an empty array.

    Declaration

    Swift

    public required init(identifier: String, dataType: RSDFormDataType)
  • Declaration

    Swift

    override open func copyInto(_ copy: RSDInputFieldObject)
  • Support for non-typed decoding of a choice list.

    Declaration

    Swift

    open class func decodeChoices(from decoder: Decoder) throws -> [RSDChoice]
  • Decoding is not supported without overriding decodeChoices().

    Declaration

    Swift

    public required init(from decoder: Decoder) throws
  • Encoding is not supported.

    Declaration

    Swift

    override open func encode(to encoder: Encoder) throws