-
Notifications
You must be signed in to change notification settings - Fork 126
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
onBlur required #51
Comments
So this is roughly how I have my components built, with required and errors being different things in the render: const errorMessage = this.props.getErrorMessage()
, isPristine = this.props.isPristine()
, isValid = this.props.isValid()
, showRequired = this.props.showRequired()
, showError = _.isBoolean(this.props.showError) ? this.props.showError : this.props.showError()
, showRequiredMessage = !isPristine && !isValid && showRequired;
{showRequiredMessage &&
<HelpBlock>{label || 'This field'} is required.</HelpBlock>}
{showErrorMessage &&
<HelpBlock>{errorMessage}</HelpBlock>} Hopefully some other people will chime in, but I would especially check out formsy-react-components by @twisty for examples of great component source. Does this answer your question? I may have interpreted it incorrectly. |
It's just my idea to make |
OKAY, two more years working on Formsy and I now understand this issue! The proposal is that when I think I understand this now, and yes, it does seem to help tighten the usage in that use case. However, on first understanding, it seems very complicated and likely to generate confusion. Does anyone else have any opinions, or want to correct any of my understanding, or advocate for it? |
hahahahaha, well better ever than never :D |
I have a case where i validate onBlur={this.props.setValue(this.props.getValue());} / onExit
Now only validation rule that i want to achieve is: Required / No empty text
And my input component code looks like:
Now the problem is: Form will say that it's not valid and it would trigger
onInvalidSubmit
But input will never get anything in
this.props.getErrorMessage()
method it will staynull
and because of that i can't catch erroronSubmit
So i spent some time looking around and going through a code, and I found out that if I implement my component like this, it would WORK!:
My component and form code looks something like:
MyInput Component
MyFormsyForm
Not sure if it's a bug or my bad implementation but, it's just feels kinda natural to add prop required and if you only have required then validationError is dedicated to required state?
Anyway, thanks for your hard work with Forms!
The text was updated successfully, but these errors were encountered: