Skip to content

Typeahead FieldType: fix choices given via newlines

...currently this field only supports choices separated by commas, which clashes if a choice contains a comma

    def create_multiplechoicetypeahead_field(self, field, options):
        options['choices'] = map(
            lambda x: (x.strip(), x.strip()),
            field.choices.split(',')
        )
        return MultipleChoiceField(
            widget=widgets.SelectMultiple(
                attrs={'class': 'is-tom-select',}
            ),
            **options,
        )
Edited by Thomas Breitner