filmov
tv
Python Flask WT-Forms MultipleSelectField Demo: Five Guys -- choosing a list of toppings

Показать описание
In this video we add to our previous WT-Forms example. We add a MultipleSelectField (a multi-select in HTML) to the previous form that had three RadioFields. Whereas the RadioField allows the user to make one choice (such as one cook level -- medium well), the MultipleSelectField allows the user to make more than one choice -- in this case multiple topping such as ketchup, mustard, and barbeque sauce. Because the data being passed is now a list, the Jinja used in the handler must accommodate working with a list. Thus we use the getlist() method and use a Jinja for loop to iterate over the items.