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

WarningField #813

Closed
alexandernst opened this issue Oct 13, 2020 · 2 comments
Closed

WarningField #813

alexandernst opened this issue Oct 13, 2020 · 2 comments
Assignees
Labels
Type: Question Questions and other discussions

Comments

@alexandernst
Copy link

I'm working with forms that require showing "alerts/warnings" on some fields after validating them.
For example, after entering a text in a field, the validation of that field should be triggered and if the value of the field matches a previously fetched array of values, the field should show a warning message of some sort (eg. "the value already exists").

The thing is that the message shouldn't be treated as a validation error, meaning that the form should still be submittable (if there are no other fields with an actual error).

If I have understood the docs correctly, there is no way for achieving this currently. Is that correct?

If that is not correct, how can I handle a case like the one I just described?

@radekmie radekmie added the Type: Question Questions and other discussions label Oct 17, 2020
@radekmie radekmie self-assigned this Oct 17, 2020
@radekmie
Copy link
Contributor

Hi @alexandernst. Yes, you are correct - there's no way of implementing such warnings using the error handling. I think the easiest would be to either create fully customized fields or just wrappers on the existing ones. In both cases, such a component would access value (and all other required props) and render the warning on its own or somehow, using field props (e.g. errorMessage with additional styling).

A completely different approach would be to create WarningField. It would work like any other field except it won't ever call onChange. Each time its value change (e.g. using useMemo), you can call some external logic to fetch and show warnings.

@radekmie
Copy link
Contributor

I think it's all clear now. If you still have any questions, feel free to reopen and ask them here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Questions and other discussions
Projects
Archived in project
Development

No branches or pull requests

2 participants