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

Creation/Edit SimpleForm required BooleanInput not being colored in red when trying to save without value

Open remi13131 opened this issue 9 years ago • 3 comments

When we try to save an entity, if some required fields are not filled, they will be surrounded by red color when trying to save. However, that is not the case with BooleanInput switches, that appears to have a value already provided when the page loads (as it is a switch, it is in either left or right position) but that is not clear for the user that it doesn't really hold any values at first. Then when the user tries to save, nothing occurs, because the forms expects this particular BooleanInput to provide a value. This looks like a bug for any basic user because the switch isn't surrounded by red, leaving him with the question "Why the hell does it not save !?"

Image below produced by opening the creation form and clicking "Save" right after Shell and sysadmin haven't colored surroundings neither values associated

admin-on-rest-github-issues-439

remi13131 avatar Mar 14 '17 10:03 remi13131

A <BooleanInput> with required: true makes no sense imo, since it does not handle null values. Try <NullableBooleanInput> instead.

fzaninotto avatar Mar 15 '17 17:03 fzaninotto

Yes I know it does not handle null values, and my SQL schema doesn't as well : it is a required value that should be true or false, and not null. Where is the problem ? A mandatory default value would be nice if required: true.

remi13131 avatar Mar 16 '17 08:03 remi13131

Ok sorry for my dumbness and wasting your time, defaultValue={true} works indeed with BooleanInput Thanks for your time

remi13131 avatar Mar 16 '17 13:03 remi13131