vibe.handlers.multichoice¶
Handler for Multichoice Data Type.
Implements the DataTypeHandler interface for multichoice. Handles widget rendering, form data processing, and runtime validation specific to this types.
MultiChoiceDict ¶
Dict subclass for multichoice values: falsy when no option is selected.
Standard dicts are truthy whenever non-empty, but a multichoice dict like
{'opt1': False, 'opt2': False} should be falsy because no option is
actually selected. Template authors expect {% if carveouts %} to be
false when nothing is checked.
MultiChoiceHandler ¶
Handler for multiple-choice checkbox groups.
__init__ ¶
__init__(definition: dict[str, Any]) -> None
Initialize with options list, normalizing values and checking for duplicates.
render_widget ¶
render_widget(name: str, current_value: dict[str, Any], error_message: str | None = None, followup_placements: dict[str, Any] | None = None, relevant_blocks: set[str] | None = None, question_definitions: dict[str, Any] | None = None, current_answers_root: Optional[NestedValue] = None, validation_errors: dict[str, Any] | None = None) -> str
Render the multichoice widget, potentially including nested followups.
process_form_data ¶
process_form_data(name: str, form_data: object) -> dict[str, Any]
Collect checkbox inputs into a dict of option -> bool, filtering to allowed options.
validate_input ¶
validate_input(value: dict[str, Any] | None, check_required: bool = True) -> str | None
Validate at least one selected when required; uses base class rule.
get_preview_placeholder_value ¶
get_preview_placeholder_value() -> str
Return HTML placeholder span for live preview.