-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Track warnings like errors #389
Comments
Can you give me an example of a warning? I have yet to truly see one in the wild. |
I think two base states are really |
@jaredpalmer In our form-heavy application we have cases where it's important we capture as much valid data upfront as possible but we're hesitant to outright declare some user input as invalid because the rules would be arbitrary ones made up by ourselves ("How long have you lived here?") and could prevent valid (but perhaps extreme) input from being submitted, a warning deals with "fat finger" cases like these quite well in my experience. @prichodko Status sounds like it can only have one value which seems somewhat limiting? Is my assumption incorrect? |
I have an app form with a select list and one of the form options requires some additional notifications to the user. We were using redux-form's warning state to highlight a reminder to the user that selecting the option requires that they understand their choice. We could have handled it with an event listener but it was a nice way of putting that message in the form input feedback area. |
@jaredpalmer any updates on this? I see PR is up and author has added tests. Just started using Formik and bumped into issue of missing warnings as they are needed for my usecase :) |
I need something like this as well. |
One of the reasons why I kept validate and warn separated is so that it's not introducing a breaking change, as validate currently only returns The other reason is that it follows similar API as redux-form. I chanced upon this example of warnings implementation on react-final-form which is quite interesting - https://codesandbox.io/s/m5qwxpr6o8. Perhaps we could achieve something like that without building in warnings mechanism in Formik itself. |
Formik is very flexible. You can achieve this in many ways. I attempted to recreate warning like validation messages, here is the code https://codesandbox.io/s/xppooqx884 Edit: I see, errors block form submission. |
Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal. |
ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we'll re-open it. |
Difference between @Andreyco's implementation and redux-form is that warn in redux-form does not mark a form as invalid stopping submission In redux-form as the name implies, a warning is just a notice that the user can then override. Allows for flexibility |
+1 for the issue. |
I have the requirement for Example warning
|
@jaredpalmer Let's reopen this! :) |
@jaredpalmer it will be an awesome enhancement. Let's reopen this. |
well, need some warnings/information on a field without making it invalid and found this issue |
@jaredpalmer Is this going to be a thing in the future? I'd like to see this feature implemented as well! 😃 |
I would also love this feature! |
Fairly big shortcoming for what is supposed to be the go-to form management library. Formik might be "very flexible" and allow you to implement this on your own. But so is vanilla html/js; I'm using a library to save time. Pretty sure there's enough upvotes here to say this should be more than an "enhancement". At the very least this issue should be reopened/re-considered. |
Can we re-open this? @jaredpalmer |
Agreed, I just ran into this same issue. Has anyone else found a workaround to show errors while still allowing form submissions? |
I just check if the field has been touched and treat it like anything I'd want to conditionally render based on a piece of state in React Formik doesn't really need to help here Just like you don't need it to conditionally change input placeholders or hints like here in a no-context sample of a form field 😇 <FormEl>
<FormikCheckboxGroup
label="Custom Label"
name="relational_ids"
options={customOptionsFromProps}
isDisabled={!customOptionsFromProps.length}
hint={`${
!anotherCustomThing ? "Select 'Other Field' to see options." : ""
}`}
values={values.relational_ids}
/>
</FormEl>; |
Think real example would be with warning, sync, and async.
|
Was just looking for a warning feature too. Its quite common when you have to do business validation that you need warnings. If you have a range for eg. 200-400kg you validate hard for below 150kg and above 500kg. Between the difference you just want to show a warning to the user he is over the valid range. Because maybe he hits the wrong number. but he still can save these values. |
I would love to have this feature added too. Thanks. |
Oh sheez this feature is what i'm looking for!! Any updates so far? BUMP |
Would love this feature as well!🙌 |
+1 for the issue. |
+1 |
Going through a lot of pain now to do it in a sensible way. Would be a great feature. Based off https://formik.org/docs/guides/form-submission Validating step is determining if Submission should happen, so maybe adding another step between that decides if Submission should happen? Something like: <Formik
onError={({ errors, values }) => {
// Check if errors include only warnings, i.e errors you want to ignore, or whatever you want
// ...
return false; // Block onSubmit
return true; // Don't block onSubmit
}}
/> On the other hand it would be nice to have this happening automatically and |
+1 |
It seems to me that Formik is dead, does anyone know if react-final-form has this feature? Because someone mentioned earlier that redux forms have warnings and I think the creator of final form was the same one who worked on redux forms if I remember correctly. |
@TamirCode well I followed each form library and can say that formik, redux-forms and react-final-forms are all dead/without contributions to it. The react-final-forms creator is the same as redux-forms. redux-forms got warnings implemented but react-final-forms do not. react-hook-form also doesn't have this but from discussions on react-hook-form/react-hook-form#1761 (comment) you can use it by creating this yourself, which also sucks. |
An example of a warning for #389 (comment)
Generally, sometimes a specific form input can have non-obvious side effects and a validation warning would be an effective way to inform the user about those side effects. Here's my specific example: Could we re-architect our app around this and do away with the special role? Yes, technically, but that's completely infeasible. Having validation warnings similar to validation errors would be a nice way to address the issue. Our working alternative involves special case logic and form state, which is uncomfortable to say the least. |
Hi, I wanted to check in on the status of this issue. Our team needs this feature and we are keen to know if any progress has occurred. Thanks! |
Hi, would have been amazing if we had this feature! Over the years, this definitely looks like one of the most requested ones. |
Hi, any updated on this one? I just had the same issue this week. |
Currently a field is either invalid or valid. In most form-heavy applications there is a grey area where a value might be outside of some "known good" parameter but not necessarily invalid, resulting in a warning that doesn't affect form-validity but is still composed of validation functions. Extending this thinking, it's possible that fields might have a number of meta states (with errors and warnings being just two) that can be built out of validators. One such (real-world) example is a "visibility" state: Is some condition met (or not met)? Then this field (or group of fields) should have their visibility affected.
I filed a similar issue for redux-form (which already has warnings) a while ago but have since shied away from redux-form.
I think this could be implemented in a future proof way (while retaining backwards compatibility) by introducing a new setter function and a new render prop (an object mapping validation type keys
error
,warning
, etc. to objects of validation results).The text was updated successfully, but these errors were encountered: