Fixes: #13681 - Resolve TypeError when default is set on a "non required" custom field

This commit is contained in:
Daniel Sheppard 2023-09-05 10:49:00 -05:00
parent 6db6616892
commit da4dc17abe

View File

@ -40,11 +40,12 @@ class DynamicMultipleChoiceField(forms.MultipleChoiceField):
def get_bound_field(self, form, field_name): def get_bound_field(self, form, field_name):
bound_field = BoundField(form, self, field_name) bound_field = BoundField(form, self, field_name)
data = bound_field.value() data = bound_field.value()
if data is not None: if data is not None:
self.choices = [ self.choices = [
choice for choice in self.choices if choice[0] in data choice for choice in self.choices if choice[0] and choice[0] in data
] ]
else:
self.choices = []
return bound_field return bound_field