Skip to content

Add TextFormField validation states (dirty, touched, etc) #18885

Closed

Description

@Chris1234567899

Another feature request:
At the moment TextFormField allows to use autovalidate activated or deactivated which is nice.
The "problem" is that if autovalidate is active, it validates the initial state of the input right away, marking a field as invalid when a user opens first time a login page for example - which does not look very nice.

A possible solution would be using additional states. Something like:

  • field is empty and untouched
  • field is empty but user wrote something before (and deleted it again)
  • field has content,
  • user is currently typing

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Jun 28, 2018
  2. pdefuns commented on Sep 21, 2018

    @pdefuns

    +1
    would be nice to have autovalidate but not from beginning on when the user didn't touch the field yet.

  3. added
    a: text inputEntering text in a text field or keyboard related problems
    on Sep 23, 2018
  4. added this to the milestone on Sep 23, 2018
  5. larssn commented on Jul 5, 2019

    @larssn

    This is pretty crucial for any Framework.

  6. liri2006 commented on Jul 6, 2019

    @liri2006

    +1
    Would be great to have this out of the box!

  7. GenuineRex commented on Aug 8, 2019

    @GenuineRex

    +1
    The closer Flutter comes to feature parity with Angular, the easier it is to move between the frameworks.

  8. GenuineRex commented on Aug 8, 2019

    @GenuineRex

    Workaround - add a bool touched=false to the form. Set to true when submitting the form and validation fails. Set audovalidate: touched on each form field. The initial editing will be clean, when the user is fixing validation issues the form fields will autovalidate.

  9. Reprevise commented on Sep 8, 2019

    @Reprevise

    +1 Angular has this feature, as well as many other Frameworks. Therefore, Flutter should have this, especially a way to check if a field is "dirty" and only mark that field as invalid.

  10. added
    a: annoyanceRepeatedly frustrating issues with non-experimental functionality
    on Sep 11, 2019
  11. removed
    a: annoyanceRepeatedly frustrating issues with non-experimental functionality
    on Mar 26, 2020
  12. filiph commented on Mar 26, 2020

    @filiph
    Contributor

    Hi, I'm removing the a: annoyance tag. Not that I think this omission in functionality isn't annoying. I just try to reserve the a: annoyance tag only for issues with existing stable features (see definition).

  13. justinmc commented on Apr 14, 2020

    @justinmc
    Contributor

    There is some great discussion about this problem in #48155 for anyone that's interested. My best current solution is to use composition like in #48155 (comment), but I'm keeping this issue open in hope of a deeper solution, or at least some docs/communication improvements.

  14. nateshmbhat commented on May 5, 2020

    @nateshmbhat

    @filiph @justinmc Please review this PR #56132
    it seems like a neat fix for the first render issue.

  15. added
    p: material_uimaterial_ui package in flutter/packages
    customer: crowdAffects or could affect many people, though not necessarily a specific customer.
    on May 5, 2020
  16. yalva commented on May 16, 2020

    @yalva

    Workaround - add a bool touched=false to the form. Set to true when submitting the form and validation fails. Set audovalidate: touched on each form field. The initial editing will be clean, when the user is fixing validation issues the form fields will autovalidate.

    Is it posible to set autoValidate to true in onChaged() of every field?

  17. added
    P2Important issues not at the top of the work list
    on May 29, 2020
  18. github-actions commented on Aug 15, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  19. locked as resolved and limited conversation to collaborators on Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: new featureNothing broken; request for a new capabilitycustomer: crowdAffects or could affect many people, though not necessarily a specific customer.frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions