Skip to content

Commit

Permalink
Support for named groups in choices
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesandres committed Dec 16, 2014
1 parent c232d17 commit b7671d6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions multiselectfield/db/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ def get_choices_default(self):
return self.get_choices(include_blank=False)

def get_choices_selected(self, arr_choices):
named_groups = arr_choices and isinstance(arr_choices[0][1], (list, tuple))
choices_selected = []
for choice_selected in arr_choices:
choices_selected.append(string_type(choice_selected[0]))
if named_groups:
for choice_group_selected in arr_choices:
for choice_selected in choice_group_selected[1]:
choices_selected.append(string_type(choice_selected[0]))
else:
for choice_selected in arr_choices:
choices_selected.append(string_type(choice_selected[0]))
return choices_selected

def value_to_string(self, obj):
Expand Down

0 comments on commit b7671d6

Please sign in to comment.