BooleanInput's defaultValue of false does not persist on initial load for validate function
dotexe0 opened this issue · 0 comments
What you were expecting:
ex. <BooleanInput label="OnOrOff" source="example" defaultValue={false} />
Setting defaultValue on BooleanInput component to false
will yield {value: false}
in validate function. Fields with defaultValue
should be set before validate function runs.
What happened instead:
In: <BooleanInput label="OnOrOff" source="example" defaultValue={false} />
yields: {}
in validate function.
Removing defaultValue
prop yields same result. Setting defaultValue={true}
yields expected result {example: true}
Toggling the BooleanInput field on and then off yields expected result {value: false}
Steps to reproduce:
Create a simple form. Console.log values in validateForm
const validateForm => values => {
console.log('values', values) // <- will yield empty object for boolean fields that have not been toggled
}
<Create {...props}>
<SimpleForm submitOnEnter={false} validate={validateForm}>
<BooleanInput label="Deletion" source="example" defaultValue={false} />
</SimpleForm>
</Create>
See: https://codesandbox.io/s/9856oq8l0p
Click + and view consoled values.
Environment
- Admin-on-rest version: 1.4.0
- React version: ^15
- Browser: Chrome