react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

Prefilled, readonly text field for `const` string types

Open mmkal opened this issue 3 years ago • 2 comments

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

  1. 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.

mmkal avatar Nov 10 '21 21:11 mmkal

Same issue, I wonder if we can create a custom widget for it

ranihorev avatar Apr 02 '22 22:04 ranihorev

@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 avatar Aug 22 '22 23:08 heath-freenome

@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.

mmkal avatar Jul 12 '23 23:07 mmkal