WTForms Flask(wtf_flask) validators how to include “required” attribute for RadioFieldflask-wtforms field requiredHow to know if an object has an attribute in PythonHow can I disable the wtforms SelectField choices validation?How do I use wtforms RadioField input to add an option with open-ended text input option?Python Flask WTForm SelectField with Enum values 'Not a valid choice' upon validationFlask WTForm validation failing for SelectField…why?Dynamic choices WTForms Flask SelectFieldFlask WTForms autofill StringField with variableWTForms not validating NumberRangeMessage not flashing on some WTForm validation methods
Is it possible to install Firefox on Ubuntu with no desktop enviroment?
Manager wants to hire me; HR does not. How to proceed?
Reviewing papers at a journal where your own work is currently submitted
Is it a good security practice to force employees hide their employer to avoid being targeted?
How do I find individuals that are participants in multiple (two) events?
Velocity of rotation of a sphere
Opposite of "Concerto Grosso"?
Why did the Death Eaters wait to reopen the Chamber of Secrets?
Why can't we feel the Earth's revolution?
Why does this Apple //e drops into system monitor when booting?
Why did the AvroCar fail to fly above 3 feet?
Interview was just a one hour panel. Got an offer the next day; do I accept or is this a red flag?
What is the theme of analysis?
Optimising matrix generation time
Can artificial satellite positions affect tides?
Nth term of Van Eck Sequence
Do Veracrypt encrypted volumes have any kind of brute force protection?
Why is gun control associated with the socially liberal Democratic party?
Is fission/fusion to iron the most efficient way to convert mass to energy?
Am I allowed to determine tenets of my contract as a warlock?
Why do the “Shtei HaLechem” not play a prominent part in the davenning for Shavuos?
Short story about psychologist analyzing demon
How effective would a full set of plate armor be against wild animals found in temperate regions (bears, snakes, wolves)?
Print "N NE E SE S SW W NW"
WTForms Flask(wtf_flask) validators how to include “required” attribute for RadioField
flask-wtforms field requiredHow to know if an object has an attribute in PythonHow can I disable the wtforms SelectField choices validation?How do I use wtforms RadioField input to add an option with open-ended text input option?Python Flask WTForm SelectField with Enum values 'Not a valid choice' upon validationFlask WTForm validation failing for SelectField…why?Dynamic choices WTForms Flask SelectFieldFlask WTForms autofill StringField with variableWTForms not validating NumberRangeMessage not flashing on some WTForm validation methods
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
What I am basically looking for is the RadioField equivalent validator for InputRequired() for WTForms. What I am mean is when you try to submit a form without entering any text into a StringField field that has the InputRequired() validator, The user gets a prompt above the text field saying "Please fill out this field". I want the User to have to pick either male or female.
This is easily done in HTML forms by just including the required attribute in your HTML form. But I cannot seem to understand what the equivalent is in WTForms for RadioField. InputRequired() and DataRequired() are both just for Input text fields and don't seem to work with any other type of fields.
If I have the below very simple WTForms class for signup form, InputRequired() works great in this instance as it gives the user the prompt "Please fill out this field" If they forget to either put in their name or surname. The form will not submit unless they give input into these fields.
class Signup(FlaskForm):
name = StringField('First Name', validators=[InputRequired()])
surname = StringField('Last Name', validators=[InputRequired()])
submit = SubmitField('Signup')
But if I have the below form that has a RadioField, What is the equivalent validator to force the User to pick Male or Female and if they do not pick one I want to give the prompt "please fill out this field"? (I am using BootStrap) I cannot seem to find any information about it. Does it exist? This question here in the second answer basically had what I am looking for Required="Required" but that has since been made obsolete since June 2018. I have tried pretty much every approach with trying to use InputRequired() or DataRequired() with RadioField but no success.
class StudentPersonalQs(FlaskForm):
gender = RadioField('Gender', choices = [('Male','Male'),('Female','Female')])
age = SelectField('Age', choices = [('12', '12'), ('13', '14'),('15', '15'), ('16', '16'),('17', '17'), ('18+', '18+')])
submit = SubmitField('Signup')
python flask flask-wtforms wtforms
add a comment |
What I am basically looking for is the RadioField equivalent validator for InputRequired() for WTForms. What I am mean is when you try to submit a form without entering any text into a StringField field that has the InputRequired() validator, The user gets a prompt above the text field saying "Please fill out this field". I want the User to have to pick either male or female.
This is easily done in HTML forms by just including the required attribute in your HTML form. But I cannot seem to understand what the equivalent is in WTForms for RadioField. InputRequired() and DataRequired() are both just for Input text fields and don't seem to work with any other type of fields.
If I have the below very simple WTForms class for signup form, InputRequired() works great in this instance as it gives the user the prompt "Please fill out this field" If they forget to either put in their name or surname. The form will not submit unless they give input into these fields.
class Signup(FlaskForm):
name = StringField('First Name', validators=[InputRequired()])
surname = StringField('Last Name', validators=[InputRequired()])
submit = SubmitField('Signup')
But if I have the below form that has a RadioField, What is the equivalent validator to force the User to pick Male or Female and if they do not pick one I want to give the prompt "please fill out this field"? (I am using BootStrap) I cannot seem to find any information about it. Does it exist? This question here in the second answer basically had what I am looking for Required="Required" but that has since been made obsolete since June 2018. I have tried pretty much every approach with trying to use InputRequired() or DataRequired() with RadioField but no success.
class StudentPersonalQs(FlaskForm):
gender = RadioField('Gender', choices = [('Male','Male'),('Female','Female')])
age = SelectField('Age', choices = [('12', '12'), ('13', '14'),('15', '15'), ('16', '16'),('17', '17'), ('18+', '18+')])
submit = SubmitField('Signup')
python flask flask-wtforms wtforms
add a comment |
What I am basically looking for is the RadioField equivalent validator for InputRequired() for WTForms. What I am mean is when you try to submit a form without entering any text into a StringField field that has the InputRequired() validator, The user gets a prompt above the text field saying "Please fill out this field". I want the User to have to pick either male or female.
This is easily done in HTML forms by just including the required attribute in your HTML form. But I cannot seem to understand what the equivalent is in WTForms for RadioField. InputRequired() and DataRequired() are both just for Input text fields and don't seem to work with any other type of fields.
If I have the below very simple WTForms class for signup form, InputRequired() works great in this instance as it gives the user the prompt "Please fill out this field" If they forget to either put in their name or surname. The form will not submit unless they give input into these fields.
class Signup(FlaskForm):
name = StringField('First Name', validators=[InputRequired()])
surname = StringField('Last Name', validators=[InputRequired()])
submit = SubmitField('Signup')
But if I have the below form that has a RadioField, What is the equivalent validator to force the User to pick Male or Female and if they do not pick one I want to give the prompt "please fill out this field"? (I am using BootStrap) I cannot seem to find any information about it. Does it exist? This question here in the second answer basically had what I am looking for Required="Required" but that has since been made obsolete since June 2018. I have tried pretty much every approach with trying to use InputRequired() or DataRequired() with RadioField but no success.
class StudentPersonalQs(FlaskForm):
gender = RadioField('Gender', choices = [('Male','Male'),('Female','Female')])
age = SelectField('Age', choices = [('12', '12'), ('13', '14'),('15', '15'), ('16', '16'),('17', '17'), ('18+', '18+')])
submit = SubmitField('Signup')
python flask flask-wtforms wtforms
What I am basically looking for is the RadioField equivalent validator for InputRequired() for WTForms. What I am mean is when you try to submit a form without entering any text into a StringField field that has the InputRequired() validator, The user gets a prompt above the text field saying "Please fill out this field". I want the User to have to pick either male or female.
This is easily done in HTML forms by just including the required attribute in your HTML form. But I cannot seem to understand what the equivalent is in WTForms for RadioField. InputRequired() and DataRequired() are both just for Input text fields and don't seem to work with any other type of fields.
If I have the below very simple WTForms class for signup form, InputRequired() works great in this instance as it gives the user the prompt "Please fill out this field" If they forget to either put in their name or surname. The form will not submit unless they give input into these fields.
class Signup(FlaskForm):
name = StringField('First Name', validators=[InputRequired()])
surname = StringField('Last Name', validators=[InputRequired()])
submit = SubmitField('Signup')
But if I have the below form that has a RadioField, What is the equivalent validator to force the User to pick Male or Female and if they do not pick one I want to give the prompt "please fill out this field"? (I am using BootStrap) I cannot seem to find any information about it. Does it exist? This question here in the second answer basically had what I am looking for Required="Required" but that has since been made obsolete since June 2018. I have tried pretty much every approach with trying to use InputRequired() or DataRequired() with RadioField but no success.
class StudentPersonalQs(FlaskForm):
gender = RadioField('Gender', choices = [('Male','Male'),('Female','Female')])
age = SelectField('Age', choices = [('12', '12'), ('13', '14'),('15', '15'), ('16', '16'),('17', '17'), ('18+', '18+')])
submit = SubmitField('Signup')
python flask flask-wtforms wtforms
python flask flask-wtforms wtforms
asked Mar 23 at 12:39
itsyourboi2468itsyourboi2468
132
132
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
IMO, you can only use this way to achieve this currently:
% for subfield in form.age %
<tr>
<td> subfield(required="required") </td>
<td> subfield.label </td>
</tr>
% endfor %
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313809%2fwtforms-flaskwtf-flask-validators-how-to-include-required-attribute-for-radi%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
IMO, you can only use this way to achieve this currently:
% for subfield in form.age %
<tr>
<td> subfield(required="required") </td>
<td> subfield.label </td>
</tr>
% endfor %
add a comment |
IMO, you can only use this way to achieve this currently:
% for subfield in form.age %
<tr>
<td> subfield(required="required") </td>
<td> subfield.label </td>
</tr>
% endfor %
add a comment |
IMO, you can only use this way to achieve this currently:
% for subfield in form.age %
<tr>
<td> subfield(required="required") </td>
<td> subfield.label </td>
</tr>
% endfor %
IMO, you can only use this way to achieve this currently:
% for subfield in form.age %
<tr>
<td> subfield(required="required") </td>
<td> subfield.label </td>
</tr>
% endfor %
answered Mar 25 at 0:57
Grey LiGrey Li
3,50911639
3,50911639
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313809%2fwtforms-flaskwtf-flask-validators-how-to-include-required-attribute-for-radi%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown