Skip to content

Widgets

hypha.apply.funds.widgets

MultiCheckboxesWidget

MultiCheckboxesWidget(*args, **kwargs)

Bases: SelectMultiple

Custom widget for Choices.js. Adds the required attributes.

Source code in hypha/apply/funds/widgets.py
def __init__(self, *args, **kwargs):
    attrs = kwargs.get("attrs", {})
    # Add the date attribute for Choices.js initialization
    attrs.setdefault("data-js-choices", "")
    attrs.setdefault("data-placeholder", "")
    kwargs["attrs"] = attrs
    super().__init__(*args, **kwargs)

MetaTermWidget

Bases: SelectMultiple

create_option

create_option(name, value, label, selected, index, subindex=None, attrs=None)
Source code in hypha/apply/funds/widgets.py
def create_option(
    self, name, value, label, selected, index, subindex=None, attrs=None
):
    disabled = False

    if isinstance(label, dict):
        label, disabled = label.get("label"), label.get("disabled")

    option_dict = super().create_option(
        name, value, label, selected, index, subindex=subindex, attrs=attrs
    )

    if disabled:
        option_dict["attrs"]["disabled"] = "disabled"
    return option_dict