ORKFormItem Class Reference

Inherits from NSObject
Conforms to NSCopying
NSSecureCoding
Declared in ORKFormStep.h

The ORKFormItem class represents a single item in a form step (ORKFormStep), and typically represents a question.

To use ORKFormItem, instantiate the object, fill in its properties, and incorporate it in an ORKFormStep object.

Usually, a form item corresponds to either a row or a section header in a form, but if the answer format is a choice answer format, it may correspond to an entire section.

Each form item generates one question result (ORKQuestionResult), which becomes a child of its step’s result (ORKStepResult).

– initWithIdentifier:text:answerFormat:

Returns an initialized form item using the specified identifier, title, and answer format.

- (instancetype)initWithIdentifier:(NSString *)identifier text:(nullable NSString *)text answerFormat:(nullable ORKAnswerFormat *)answerFormat

Parameters

identifier

The string that identifies the form item, which should be unique within the form step.

text

The text displayed as a prompt for the form item’s question.

answerFormat

The answer format for the form item.

Return Value

An initialized form item.

Declared In

ORKFormStep.h

– initWithIdentifier:text:answerFormat:optional:

Returns an initialized form item using the specified identifier, title, optionality and answer format.

- (instancetype)initWithIdentifier:(NSString *)identifier text:(nullable NSString *)text answerFormat:(nullable ORKAnswerFormat *)answerFormat optional:(BOOL)optional

Parameters

identifier

The string that identifies the form item, which should be unique within the form step.

text

The text displayed as a prompt for the form item’s question.

answerFormat

The answer format for the form item.

optional

A Boolean that determines whether the item is optional

Return Value

An initialized form item.

Declared In

ORKFormStep.h

– initWithSectionTitle:

Returns an initialized form item using the specified section title.

- (instancetype)initWithSectionTitle:(nullable NSString *)sectionTitle

Parameters

sectionTitle

The title of the section.

Return Value

An initialized form item for use as a section header in a form.

Declared In

ORKFormStep.h

  identifier

A string that identifies the form item.

@property (nonatomic, copy, readonly) NSString *identifier

Discussion

The identifier should be unique within the form step that contains the form item. The identifier is reproduced in the question result object (ORKQuestionResult) generated for the item.

Declared In

ORKFormStep.h

  optional

A Boolean value indicating whether the form item is optional.

@property (nonatomic, getter=isOptional) BOOL optional

Discussion

The default value of this property is YES. When the value is YES, this form item doesn’t need to be answered for the Continue button of a step form to be enabled.

Declared In

ORKFormStep.h

  text

A localized string that describes the form item.

@property (nonatomic, copy, readonly, nullable) NSString *text

Discussion

If the descriptive text is sufficiently short, you can display it as a prompt next to the item. If it is too long to display next to the item, you can display it above the item.

Declared In

ORKFormStep.h

  placeholder

A localized string that displays placeholder information for the form item.

@property (nonatomic, copy, nullable) NSString *placeholder

Discussion

You can display placeholder text in a text field or text area to help users understand how to answer the item’s question. A placeholder string is not appropriate for choice-based answer formats.

Declared In

ORKFormStep.h

  answerFormat

The format of the expected answer for the item.

@property (nonatomic, copy, readonly, nullable) ORKAnswerFormat *answerFormat

Discussion

The answer format specifies the type of answer that is expected, in addition to any constraints on valid answers.

By default, the answer format is nil. The answer format for a form item that represents a section header is always nil, because no answer is expected.

Declared In

ORKFormStep.h

– confirmationAnswerFormItemWithIdentifier:text:errorMessage:

Returns an form item that can be used for confirming a text entry.

- (ORKFormItem *)confirmationAnswerFormItemWithIdentifier:(NSString *)identifier text:(nullable NSString *)text errorMessage:(NSString *)errorMessage

Parameters

identifier

The identifier for the ORKFormItem that is returned.

text

The text for the ORKFormItem that is returned.

errorMessage

The error message to display if the fields do not match

Return Value

An ORKFormItem with the indicated identifier and text and an ORKAnswerFormat that is appropriate for confirming the input form item.

Discussion

This form item is intended to be used with an ORKFormStep in order to confirm a previous formItem input. Example usage includes a password or participant identifier that is used to anonymously identify a study participant.

Currently, only ORKTextAnswerFormat is supported. Unsupported ORKAnswerFormat types will throw an exception.

The answer format for this item produces an ORKBooleanQuestionResult object.

Declared In

ORKFormStep.h