UnitField
objects define simple components for data collection.
Parameter | Type | Default | Description |
---|---|---|---|
type* | string | One of text , boolean , number , datetime , or category , select , time_range . | |
field_id* | string | A unique identifier for the field, which should not change among tasks within a project. | |
title* | string | Field title to be displayed to taskers. This should be short and singular. This may change among tasks within a project. Must not be an empty string. | |
description | string | undefined | A brief description about what the response should be. This may change among tasks within a project. |
hint | string | undefined | Longer explanation of why the field exists and how it should be used. Renders as a tooltip. |
required | boolean | false | Determines whether or not a response for this field is required. |
min_responses_required | integer | 1 | The minimum number of separate annotations allowed for this field. Must be larger than 0. |
max_responses_required | integer | 1 | The maximum number of separate annotations allowed for this field. Must be larger than or equal to min_responses_required , with an upper bound of 100. |
conditions | array_object | undefined | A set of conditions which must be satisfied for this field to be shown. |
Additional Fields | See the TextField, BooleanField, NumberField, DatetimeField, and CategoryField sections. |
Beta: Conditional Fields
Sometimes a field should only be presented if specific choices are selected for other fields. In these cases, you can specify the conditions — the dependent questions and corresponding sets of choices.
The conditions
property should have the following structure: an array of objects, which define one set of conditions allowing the field to be shown. The operators AND ({ }
), OR ([ ]
), and NOT (not
) are supported, so you could specify an arbitrary set of fields and choices. Each set may contain objects or arrays with the following:
- Key: the
field_id
of the dependent field - Value: an object specifying the desired choices for the dependent field.
For example conditions, please check out the code on the right.
Conditions currently only work with dependent fields of type CategoryField. It is valid syntax on other fields, but may raise errors or undefined behavior.
// Example of UnitField with conditions
{
type: "category",
field_id: "occlusion",
title: "Is there occlusion in the image?",
choices: [{label: 'None', value: '0' },
{label: 'A little', value: '1'},
{label: 'A lot', value: '2'}],
conditions: [{}],
},
{
type: "category",
field_id: "occlusion_detail",
title: "What is the cause of the occlusion?",
choices: [{label: 'Rain', value: 'rain'},
{label: 'Shadow', value: 'shadow'}],
conditions: [{
occlusion: ['1', '2'], // show if 1 or 2 are selected
// equivalently {not: [[], ['0']}
// equivalently [{not: []}, {not: ['0']}]
// equivalently [['1'],['2']]
}],
},
{
type: "text",
field_id: "a_lot_of_shadow",
title: "Please describe why there is so much shadow.",
conditions: [{
// show if 2 and shadow are selected in their respective fields
occlusion: ['2'],
occlusion_detail: ['shadow'],
}],
},