Skip to content

Widgets

hypha.apply.funds.widgets

Select2MultiCheckboxesWidget

Select2MultiCheckboxesWidget(*args, **kwargs)

Bases: Select2MultipleWidget

Source code in hypha/apply/funds/widgets.py
def __init__(self, *args, **kwargs):
    attrs = kwargs.get("attrs", {})
    attrs.setdefault("data-placeholder", "items")
    kwargs["attrs"] = attrs
    super().__init__(*args, **kwargs)

Media

js class-attribute instance-attribute
js = (static('js/select2.multi-checkboxes.js'), static('js/django_select2-checkboxes.js'))

build_attrs

build_attrs(*args, **kwargs)
Source code in hypha/apply/funds/widgets.py
def build_attrs(self, *args, **kwargs):
    attrs = super().build_attrs(*args, **kwargs)
    attrs["class"] = attrs["class"].replace(
        "django-select2", "django-select2-checkboxes"
    )
    return attrs

MetaTermSelect2Widget

Bases: Select2MultipleWidget

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