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;








2















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')









share|improve this question




























    2















    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')









    share|improve this question
























      2












      2








      2








      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')









      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 12:39









      itsyourboi2468itsyourboi2468

      132




      132






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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 %





          share|improve this answer























            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
            );



            );













            draft saved

            draft discarded


















            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









            0














            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 %





            share|improve this answer



























              0














              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 %





              share|improve this answer

























                0












                0








                0







                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 %





                share|improve this answer













                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 %






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 0:57









                Grey LiGrey Li

                3,50911639




                3,50911639



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해