A list of tuples made sense before dicts were ordered by default, but we're now already using dicts for optgroup support. It'd be nice to be able to do:
class PastebinEntry(Form):
language = SelectField(
'Programming Language',
choices={
'cpp': 'C++',
'py': 'Python',
'text': 'Plain Text',
},
)
form = PastebinEntry()
del form.choices['cpp'] # instead of having to iterate over .choices and filter out 'cpp'
This could still coexist with an optgroup version:
class PastebinEntry(Form):
language = SelectField(
'Programming Language',
choices={
'Actual languages': {'cpp': 'C++', 'py': 'Python'},
'Generic': {'text': 'Plain Text'},
},
)
or the current allowed format:
class PastebinEntry(Form):
language = SelectField(
'Programming Language',
choices={
'Actual languages': [('cpp', 'C++'), ('py', 'Python')],
'Generic': [('text', 'Plain Text')],
},
)
Happy to provide a PR if this sounds sensible!
A list of tuples made sense before dicts were ordered by default, but we're now already using dicts for optgroup support. It'd be nice to be able to do:
This could still coexist with an optgroup version:
or the current allowed format:
Happy to provide a PR if this sounds sensible!