Allow to unset the value of a non-required enum with the Dropdown Edit Widget

What is the feature?

When using a non-required enum in the forest-admin schema such as:

{
      "field": "outcome",
      "type": "Enum",
      "defaultValue": null,
      "enums": [ "Approved", "Rejected"],
      "integration": null,
      "isFilterable": true,
      "isReadOnly": false,
      "isRequired": false,
      "isSortable": true,
      "isVirtual": false,
      "reference": null,
      "inverseOf": null,
      "validations": []
    }

you cannot reset the value to null in Forest Admin.
It would be nice to have a way to do this (an empty value in the dropdown or a button to empty it)

What problem does this solve for you?

I’m forced to add a ‘dummy’ value in the select that I map to null in my code. It would be much simpler to have the front send the null value directly.

Who else would be using this feature?

Anybody using editable non-required dropdowns. I can’t tell much more…

Hey, @Vincent_Francois !
Thanks for the suggestion, I’m pushing it to our product team :slight_smile:

1 Like

Ive just hit this problem too, any suggested workarounds ?

1 Like

Have you tried to set the field to enable search? This seems to change the field to a compound select and provides an ‘x’ you can use to clear the field. With the field cleared, if the field in the database table is nullable, save will succeed and a null value is stored.

@Mike_Bissett The only workaround I found was adding a ‘dummy’ value to handle the unset. I haven’t checked for a while for other solutions, though, but somehow it does the job :man_shrugging:

1 Like

Hi @Vincent_Francois, @Mike_Bissett, @Neil_Clifton,

This is something that is now natively handled by Forest Admin.
See my example below:

Field definition in the schema:

Field select input in the UI:

Do you confirm, it also works on your end?

1 Like

I’ve just checked but we actually removed the dropdown from our admin so I can’t verify that your solution works on my end.
I’ll let the other answer or answer later if we have the use case.

Thanks for letting us know anyway!