Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

BooleanInput's defaultValue of false does not persist on initial load for validate function #19

Open
dotexe0 opened this issue May 23, 2018 · 0 comments

Comments

@dotexe0
Copy link

dotexe0 commented May 23, 2018

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant