Skip to content

empty_label not displayed for ModelSelect2MultipleWidget #174

Open
@rez0n

Description

@rez0n

Describe the bug
Hi @codingjoe
I assume it is something related to this issue.
empty_label is not displays for the ModelSelect2MultipleWidget on page loads, but if I select one of options and then clear selection it gonna showed.

Code Snippet

field_name = forms.ModelChoiceField(
        required=False,
        blank=True,
        queryset=Organisation.objects.all(),
        widget=OrganisationsPickWidget(
            attrs={
                'class': 'form-control',
                'data-minimum-input-length': 0,
            },
        ),
    )

def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)
    self.fields['field_name'].empty_label = 'empty_label text'

Screenshots

Open.
2022-11-09 at 20 09 00

Select.
2022-11-09 at 20 09 16

Cleared selection
2022-11-09 at 20 09 53

Thanks in advance.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions