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

Read-only field with generated value (uuid)?

Open briandonahue opened this issue 2 years ago • 2 comments

Prerequisites

What theme are you using?

bootstrap-4

What is your question?

This seems obvious, but I can't find it in the docs or any issues, at least with the keywords I've tried searching with. I have many fields in my schema that require uuids. I'd like to just auto-generate those for new entries and make them read-only as a reference for the user. I see that I can create a custom widget to do this, but then I have to recreate the HTML for the TextWidget. I'd like to just use a text widget, but set disabled=true and generate a uuid value if it's not in the formData.

How can I achieve that?

briandonahue avatar Oct 20 '22 17:10 briandonahue

You could copy the source for the BaseInputTemplate and modify it for your purposes and replace the default template with yours. See the templates docs for more information on how to do this.

heath-freenome avatar Oct 21 '22 16:10 heath-freenome

This issue has been automatically marked as possibly close because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

stale[bot] avatar Jan 20 '24 17:01 stale[bot]

This issue was closed because of lack of recent activity. Reopen if you still need assistance.

stale[bot] avatar Feb 19 '24 19:02 stale[bot]