react-forms icon indicating copy to clipboard operation
react-forms copied to clipboard

When passing the initialValues { SELECT_OPTION : 0 } in schema then in select that value not showing as selected.

Open anjalikalsariya opened this issue 2 years ago • 3 comments

Select field

{
   "name": "SELECT_OPTION",
   "label": "test",
   "options": [
     { "label": "none", "value": 0 },
     { "label": "2", "value": 2 },
   ],
   "component": "select"
 },
Note:  I'm using the ant-component-mapper.

Can you help me for it?

anjalikalsariya avatar Jan 04 '24 08:01 anjalikalsariya

This is because javascript resolves 0 as false so the select thinks there is no value. @Hyperkid123 we could probably fix it. As a workaround, @anjalikalsariya, use string and then convert it to a number. 😸

rvsia avatar Jan 04 '24 08:01 rvsia

Correct @rvsia. I got it. For now, let me add that convert solution. Later, If anything will be changing in the library to fix this issue that will be more helpful.

anjalikalsariya avatar Jan 04 '24 08:01 anjalikalsariya

One more thing is when the value is 0 and validation is required then also throws an error for an empty field. Validation does not work with the value 0 integer.

anjalikalsariya avatar Jan 04 '24 14:01 anjalikalsariya