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

UseInput isRequired and meta error #5122

Closed
L-Luciano opened this issue Aug 7, 2020 · 5 comments · Fixed by #5812
Closed

UseInput isRequired and meta error #5122

L-Luciano opened this issue Aug 7, 2020 · 5 comments · Fixed by #5812

Comments

@L-Luciano
Copy link

Is your feature request related to a problem? Please describe.
I have an HOC to manage multilangue on TextInput and I would like my text input display my error message and add required on label message.

I override name of TextInput with 'source+language selected'.
I have a required validate function with default language which verify the default language is setted.
structure :
{ fr: "mon texte", en : "my text"}
If I pass my custom required validate function to textinput :
the value send to validator is only "mon texte" and display error all the time.

If I remove this validate, my validator works but the error is not displayed. Moreover, the label hasn't got the required option.

Describe the solution you'd like
I would like the isRequired is initialized like input or meta in useInput :

 // If there is an input prop, this input has already been enhanced by final-form
    // This is required in for inputs used inside other inputs (such as the SelectInput inside a ReferenceInput)
    if (options.input) {
        return {
            id: id || source,
            input: options.input,
            meta: options.meta,
            isRequired: isRequired(validate),
        };
    }

Manage the display error if my text input receive error message in meta props.

Additional context
It's complicated to add an source example because it's a large project.

@djhi
Copy link
Collaborator

djhi commented Aug 10, 2020

Hi, and thanks for your question. As explained in the react-admin contributing guide, the right place to ask a "How To" question, get usage advice, or troubleshoot your own code, is StackOverFlow.

This makes your question easy to find by the core team, and the developer community. Unlike Github, StackOverFlow has great SEO, gamification, voting, and reputation. That's why we chose it, and decided to keep GitHub issues only for bugs and feature requests.

So I'm closing this issue, and inviting you to ask your question at:

http://stackoverflow.com/questions/tagged/react-admin

And once you get a response, please continue to hang out on the react-admin channel in StackOverflow. That way, you can help newcomers and share your expertise!

@djhi djhi closed this as completed Aug 10, 2020
@L-Luciano
Copy link
Author

Hello,
Sorry i was on holiday but it's not a "How To".
The "useInput" method use the option properties to manage "input" & "meta" but not for "isRequired".

Is it possible to change it and let the choice at developer ?

for example :

isRequired: options.isRequired || isRequired(validate)

@djhi
Copy link
Collaborator

djhi commented Aug 31, 2020

Yes, can you create a PR ?

@djhi djhi reopened this Aug 31, 2020
@L-Luciano
Copy link
Author

Ok,

I'll try to do it if I have time to fork project and improve that.
I never did that before so I need time.

Regards,

@djhi
Copy link
Collaborator

djhi commented Aug 31, 2020

No problem. As this will be a new feature, please target the next branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants