-
Notifications
You must be signed in to change notification settings - Fork 434
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
How not to validate on first render? #254
Comments
In twisty/formsy-react-components we set a renderErrorMessage: function() {
if (!this.showErrors()) {
return '';
}
var errorMessages = this.getErrorMessages() || [];
return errorMessages.map((message, key) => {
return (
<span key={key} className="help-block validation-message">{message}</span>
);
});
},
showErrors: function() {
if (this.isPristine() === true) {
if (this.props.validatePristine === false) {
return false;
}
}
return (this.isValid() === false);
} |
@vijayrawatsan Have you came up with the solution? I am stuck with 0.14.1 and using the @twisty solution it only 'hide' the errors, but If I have a button controlled by the validity of the form, my input is anyway validated on the first render and so not valid. In my specific case: I have a input that has a |
I used https://github.com/mbrookes/formsy-material-ui |
@vijayrawatsan it does not seems a optimal solution for my case, since I don't want to use material design. I guess I will need to do somework for myself. |
@ciaoben |
@vijayrawatsan I managed to solved now, here how I did this, for future reference: I noticed that in the last version the problem was not present, so I searched in the commits, and voilà: The |
Currently I'm experiencing this issue. After going through code, I see that the validation is triggered immediately on componentDidMount() of component (see https://github.com/christianalfoni/formsy-react/blob/master/src%2Fmain.js#L73). So the possible solution is to introduce one more boolean option on to indicate whether the validation is triggered at first render or notI submitted PR #277 to fix this |
How not to validate on first render?
So that all the valid fields are not in red just after render?
The text was updated successfully, but these errors were encountered: