Toloka documentation

ButtonRadioGroupFieldV1

toloka.client.project.template_builder.fields.ButtonRadioGroupFieldV1 | Source code

ButtonRadioGroupFieldV1(
    self,
    data: Optional[BaseComponent] = None,
    options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None,
    *,
    hint: Optional[Any] = None,
    label: Optional[Any] = None,
    validation: Optional[BaseComponent] = None,
    version: Optional[str] = '1.0.0'
)

A component with buttons that allow the user to choose between the specified values.

The minimum number of elements is one. Any type of data can be returned.

The size of the button is determined by the length of the text on it.

Parameters Description

Parameters Type Description
data Optional[BaseComponent]

Data with values that will be processed or changed.

options Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]]

Array of information about the buttons.

hint Optional[Any]

Hint text.

label Optional[Any]

Label above the component.

validation Optional[BaseComponent]

Validation based on condition.

Examples:

How to add buttons for classification task.

classification_buttons = tb.fields.ButtonRadioGroupFieldV1(
    tb.data.OutputData(path='class'),
    [
        tb.fields.GroupFieldOption('Cat', 'cat'),
        tb.fields.GroupFieldOption('Dog', 'dog'),
    ],
    validation=tb.conditions.RequiredConditionV1(hint='Choose one of the answer options'),
)