Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
This repository was 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

@dotexe0

Description

@dotexe0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions