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

Set default values for additionalProperties

Open jsj1027 opened this issue 2 years ago • 3 comments

Prerequisites

What theme are you using?

core

Is your feature request related to a problem? Please describe.

Unable to set the default values for the additionalProperties key-value combos.

Currently the key is always "newKey" and the value is "New Value". It would be helpful if we could customize what the default key is in the jsonschema. It would be also nice if you could just have the fields show up empty rather than with a value at all.

Describe the solution you'd like

Something like any of these in the jsonschema would be nice.

Allow both to have defaults
"additionalProperties": {
    "type": "string",
  "default_key": "Key",
  "default_value": "Value",
  }
 
 Allow just the value to have a default 
"additionalProperties": {
    "type": "string",
    "default": "Value",
  }
  
Allow it to just appear empty.
"additionalProperties": {
    "type": "string",
    "blank/empty": true, default of false
  }

Describe alternatives you've considered

Not really just what alternatives would be useful, maybe something you could set in the uiSchema? Also if this is already possible please let me know, I think ive tried everything on the playground and couldn't figure it out.

jsj1027 avatar Oct 20 '23 16:10 jsj1027

@jsj1027 This would be a great feature and we would gladly review and accept a pull request to add it!

nickgros avatar Oct 20 '23 19:10 nickgros

I'd love to add it personally, but I'm pretty Javascript rusty. So any guidance/direction on this would be appreciated.

jsj1027 avatar Oct 23 '23 18:10 jsj1027

I will just try to this problem 👍

tomatommy-bs avatar May 24 '24 06:05 tomatommy-bs

Thanks @tomatommy-bs , this was added in v5.18.5

nickgros avatar Jul 08 '24 12:07 nickgros