react-jsonschema-form
react-jsonschema-form copied to clipboard
Prefilled, readonly text field for `const` string types
Prerequisites
- [x] I have read the documentation;
- ~[ ] In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.~
- [x] I'm providing a shared playground link demonstrating the issue.
Description
[Description of the bug or feature]
Steps to Reproduce
- Have a schema using
{ "type": "string", "const": "something" }
Expected behavior
The input
should have the const
value already filled in, and have readonly=true
Actual behavior
The input
is just a regular textbox, and the user has to type the exact value of const
manually (without even a hint of what the value should be)
Version
3.2.0
I'd be happy to open a PR to improve this if someone could point me in roughly the right direction.
Same issue, I wonder if we can create a custom widget for it
@mmkal Are you still willing to fix this? Some refactoring that was done in version 5 should make fixing this fairly simple. There is a new method in @rjsf/utils
called getInputProps()
that would be the place to add the fix. The code can be found in the rjsf-v5
branch until it is merged into the master branch when the v5 beta is published
@heath-freenome sorry I missed this message. I'm not using rjsf at the moment any more, so probably won't do this any time soon.