Python Flask WT-Forms Demo: Radio Buttons

preview_player
Показать описание
In this video we look at a Python-Flask app that uses WT-Forms to create a form that allows the user to use three sets of radio buttons (RadioField) to choose: 1) the type of burger (hamburger, cheeseburger, etc.); 2) the cook level (rare, medium rare, etc.); and 3) fries (yes or no). In the RadioField, we establish A) a label, B) the choices -- which consists of a list of tuples with the values (behind the scenes) and what the user sees, C) a InputRequired validator that forces the user to choose one of the radio button options, and D) a render_kw dictionary that assigned the form element to a CSS class. (The CSS class can also be applied by using Jinja). We use some "tricks" in Jinja on the handler page -- like splitting and casting one of the tokens as a float so we can display the desired output which includes the user's total if they chose fries.
Рекомендации по теме
Комментарии
Автор

Hi, Is it possible to put all radio button in one line also. Nice video, learnt something.

VidyaGupta-ql
Автор

Can you share the GitHub link of this project ?

cobraigmoments