Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form validation doesn't enable submit button #1965

Closed
alexrudd opened this issue Feb 16, 2021 · 1 comment
Closed

Form validation doesn't enable submit button #1965

alexrudd opened this issue Feb 16, 2021 · 1 comment
Labels
blocker Items that would block a forthcoming release bug Something isn't working

Comments

@alexrudd
Copy link

Describe the bug:

When creating a form with entries that include validation methods, typing valid input into those entries does not enable the form's submit button. However, typing input, deleting that input, and then typing it again does enable the form's submit button

To Reproduce:

Steps to reproduce the behaviour:

  1. Create form with entries that include validation and an OnSubmit function
  2. Render the form
  3. Type valid input into the form's entries
  4. Observe that the submit button stays disabled
  5. Delete and then re-enter the valid input
  6. Observe that the submit button is now enabled

Screenshots:

formbug

Example code:

Code from the above gif:

username := widget.NewEntry()
username.SetPlaceHolder("username")
username.Validator = func(s string) error {
    if s == "" {
        return errors.New("please specifiy a username")
    }

    return nil

}

password := widget.NewPasswordEntry()
password.SetPlaceHolder("password")
password.Validator = func(s string) error {
    if s == "" {
        return errors.New("please specifiy a password")
    }

    return nil
}

rememberCheck := widget.NewCheck("Remember my password", nil)

form := widget.NewForm(
    widget.NewFormItem("Username", username),
    widget.NewFormItem("Password", password),
    widget.NewFormItem("", rememberCheck),
)

form.SubmitText = "Login"
form.OnSubmit = func() {
    username.Disable()
    password.Disable()
    rememberCheck.Disable()
    defer username.Enable()
    defer password.Enable()
    defer rememberCheck.Enable()

    success := pres.Login(username.Text, password.Text, rememberCheck.Checked)
    if success {
        onSucess()
    }
}

Device (please complete the following information):

  • OS: Windows
  • Version: 10.0.19042
  • Go version: go1.15.8
  • Fyne version: v2.0.0
@alexrudd alexrudd added the bug Something isn't working label Feb 16, 2021
@andydotxyz andydotxyz added the blocker Items that would block a forthcoming release label Feb 17, 2021
Jacalz added a commit that referenced this issue Feb 21, 2021
Guarantee widget.Form tracks all entry validation changes, fixes #1965
@Jacalz
Copy link
Member

Jacalz commented Feb 21, 2021

Fixed on the develop branch as of 7d2b239.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Items that would block a forthcoming release bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants