Python Flask WT-Forms Demo: Radio Buttons
HTML-код
- Опубликовано: 21 авг 2024
- 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.
In the example posted and discussed in the video, there is a class to eliminate the bullets. You can do something similar by having a "no_new_line" class. And then in the CSS, have code
like
ul.no_new_line li {
display: inline;
}
I think you can also use inline-block if you want to have a uniform width, but my labels are already styled as inline-block.
www1.lasalle.edu/~blum/c341wks/WTForms_RadioButtons_FiveGuys.zip
Can you share the GitHub link of this project ?
www1.lasalle.edu/~blum/c341wks/WTForms_RadioButtons_FiveGuys.zip
www1.lasalle.edu/~blum/c341wks/WTForms_RadioButtons_FiveGuys.zip
www1.lasalle.edu/~blum/c341wks/WTForms_RadioButtons_FiveGuys.zip