RSDFormUIStepObject

open class RSDFormUIStepObject : RSDUIStepObject, RSDFormUIStep, RSDSurveyNavigationStep

RSDFormUIStepObject is a concrete implementation of the RSDFormUIStep and RSDSurveyNavigationStep protocols. It is a subclass of RSDUIStepObject and can be used to display a navigable survey.

  • The inputFields array is used to hold a logical subgrouping of input fields.

    Declaration

    Swift

    open private(set) var inputFields: [RSDInputField]
  • Default initializer.

    Declaration

    Swift

    public init(identifier: String, inputFields: [RSDInputField], type: RSDStepType? = nil)

    Parameters

    identifier

    A short string that uniquely identifies the step.

    inputFields

    The input fields used to create this step.

    type

    The type of the step. Default = RSDStepType.form

  • Identifier to skip to if all input fields have nil answers.

    Declaration

    Swift

    open var skipToIfNil: String?
  • Identifier for the next step to navigate to based on the current task result.

    Note

    The conditional rule is ignored by this implementation of the navigation rule. Instead, this will evaluate any survey rules and the direct navigation rule inherited from RSDUIStepObject.

    Declaration

    Swift

    open override func nextStepIdentifier(with result: RSDTaskResult?, conditionalRule: RSDConditionalRule?, isPeeking: Bool) -> String?

    Parameters

    result

    The current task result.

    conditionalRule

    The conditional rule associated with this task. (Ignored)

    isPeeking

    Is this navigation rule being called on a result for a step that is navigating forward or is it a step navigator that is peeking at the next step to set up UI display? If peeking at the next step then this parameter will be true.

    Return Value

    The identifier of the next step.

  • Initialize from a Decoder. This implementation will query the RSDFactory attached to the decoder for the appropriate implementation for each input field in the array.

    Note

    This method will also check for both an array of input fields and in order to support existing serialization methods defined prior to the developement of the Swift 4 Decodable protocol, it will also recognize a single input field defined inline as a single question.

  • example:

        // Example JSON dictionary that includes a date, integer, and multiple choice question defined
        // in an array of dictionaries keyed to "inputFields".
        let json = """
            {
            "identifier": "step3",
            "type": "form",
            "title": "Step 3",
            "text": "Some text.",
            "inputFields": [
                            {
                            "identifier": "foo",
                            "dataType": "date",
                            "uiHint": "picker",
                            "prompt": "Foo",
                            "range" : { "minimumDate" : "2017-02-20",
                                        "maximumDate" : "2017-03-20",
                                        "codingFormat" : "yyyy-MM-dd" }
                            },
                            {
                            "identifier": "bar",
                            "dataType": "integer",
                            "prompt": "Bar"
                            },
                            {
                            "identifier": "goo",
                            "dataType": "multipleChoice",
                            "choices" : ["never", "sometimes", "often", "always"]
                            }
                           ]
            }
        """.data(using: .utf8)! // our data in native (JSON) format
    
        // Example JSON dictionary that includes a multiple choice question where the input field properties are
        // defined inline and *not* using an array.
        let json = """
            {
            "identifier": "step3",
            "type": "form",
            "title": "Step 3",
            "dataType": "multipleChoice",
            "choices" : ["never", "sometimes", "often", "always"]
            }
        """.data(using: .utf8)! // our data in native (JSON) format
    
  • Throws

    DecodingError

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    decoder

    The decoder to use to decode this instance.

  • Instantiate a step result that is appropriate for this step. The default for this class is a RSDCollectionResultObject.

    Declaration

    Swift

    open override func instantiateStepResult() -> RSDResult

    Return Value

    A result for this step.

  • Validate the step to check for any configuration that should throw an error. This class will check that the input fields have unique identifiers and will call the validate() method on each input field.

    Throws

    An error if validation fails.

    Declaration

    Swift

    open override func validate() throws