JSON Schema Form ui:emptyValue Issues

We're seeing issues where the JSON scheme form is not following the ui:emptyValue that we've given it. IN our form we've added in ui:emptyValue: "" and also tried as an emtpy string " " but the form itself doesn't not comply with the empty value and continues to attempt to validate the field on submission. I'm curious if you have a working example of ui:emptyValue in Retool? If not I'm curious if we're either doing it incorrectly or that Retool isn't incorrectly handling this. I did see in the release notes that there was a bug with emptyValue but theoretically was patched.


It does seem like there is a bug here, as the behavior in Retool differs from the behavior in the github sample. As a workaround, I think you can use "ui:emptyValue": undefined, which seems to work with the validation as expected.

1 Like

So I tried this out, but when using undefined the UI Schema editor box turns red and says that this isn't valid JSON.

Screen Shot 2021-05-18 at 5.47.41 PM

the only change I made was changing the ui:emptyValue value from " " to undefined

I noticed that it fails linting, but it did seem to work. In your case does it also not work?

Im not sure if it's that I have a fairly length/complex form, but when I put undefined in there as a value it doesn't work. It still tries to validate the field and requiring it to be a string as well as other strange behaviors. For example when I add the undefined value in there, all of a sudden a ui component that is hidden becomes visible and has issues being validated.

Ah, ok, this may not be a viable workaround then. It might have only worked because my form was very simple. Are you able to share an export of the app so that I can experiment more with this?

Hey Mark, I can do that — can you shoot me an email at zachzimbler@gmail.com so I can share privately?

So here's what we've found:

  • So if your form is empty and then you add content to a blank form, it actually obey's the ui:emptyValue value
  • If your form is passed data when you view it, e.g you're editing data then the JSON schema form doesn't really understand how to utilize the ui:emptyValue value. This is especially true if your data store returns null data.

Work Around:
I was able to add a transformer to my database request that changed it fields from null to undefined. Once changed to undefined, even when editing data it would properly follow the ui:emptyValue value on validation

1 Like