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

[FormBuilderField]: Add "resetError" method #1390

Open
1 task done
dimzeta opened this issue May 5, 2024 · 0 comments
Open
1 task done

[FormBuilderField]: Add "resetError" method #1390

dimzeta opened this issue May 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@dimzeta
Copy link

dimzeta commented May 5, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

9.2.1

What you'd like to happen

The form is validated only when the user click on submit. At this moment, some fields are invalidate, with an error message.

I would like on remove the error message as soon as the user updates the value.

Example:


FormBuilder(
  key: _formKey,
  autovalidateMode: AutovalidateMode.disabled,
  child: Column(
    children: [
      FormBuilderTextField(
        name: 'email',
        autofillHints: const [
          AutofillHints.email,
        ],
        keyboardType: TextInputType.emailAddress,
        // * reset field error when value changes
        // * using Form Key
        onChanged: (value) => _formKey.currentState?.fields['email']?.resetError(),
        // * OR using Field Key
        onChanged: (value) => _fieldKey.currentState?.resetError(),
        validator: FormBuilderValidators.compose([
          FormBuilderValidators.required(),
          FormBuilderValidators.email(),
        ]),
      ),
    ],
  ),
);

Alternatives you've considered

No response

Aditional information

No response

@dimzeta dimzeta added the enhancement New feature or request label May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant