React-admin: Default value not displayed with BooleanInput

Created on 19 Dec 2018  路  7Comments  路  Source: marmelab/react-admin

Hello,
when I set the default value true, it is well managed in my filter but the displayed value is always equal to false.

<BooleanInput
  source="account.active"
  label="active"
  defaultValue={true}
/>

capture d ecran 2018-12-19 a 17 06 11

I think it's a bug. Same problem with NullableBooleanInput.

Other information:

Environment

  • React-admin version: 2.5.2
  • React version: 16.6.3
  • Browser: Chrome
bug

Most helpful comment

As mentioned above, the default value does not work with BooleanInput and NullableBooleanInput when the source is an object,
for example accounts.commented.
Show https://codesandbox.io/s/k3lq8j87v5

All 7 comments

It does work for me: https://codesandbox.io/s/0q6583162p
Look at the Post Creation form, the "commentable" boolean input.

Do you have a bit more context ? Which version of Material UI do you use?

@Kmaschta it seems to be in the context of a Filter form

Yes I also tested on the sandbox and it works.
In fact the default value does not work when the source is an object, for example account.active.

Interesting clue: it seems to be working on RA 2.3: https://codesandbox.io/s/l5wknxqmwq (see the Post List filters)
I'm trying to figure out how to make RA 2.5 work on CodeSandbox.

OK ! I managed to get RA 2.5 working with CodeSandbox thanks to Fran莽ois.

Here it is, on the PostList, there is a BooleanInput as a filter with defaultValue is true: https://codesandbox.io/s/y0xx53yy0v

image

And it seems to be working.
Do you know what can be different from your codebase?

As mentioned above, the default value does not work with BooleanInput and NullableBooleanInput when the source is an object,
for example accounts.commented.
Show https://codesandbox.io/s/k3lq8j87v5

I can't reproduce this issue anymore on V3. Feel free to reopen if I'm wrong

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pixelscripter picture pixelscripter  路  3Comments

mbj36 picture mbj36  路  3Comments

samanmohamadi picture samanmohamadi  路  3Comments

ilaif picture ilaif  路  3Comments

kdabir picture kdabir  路  3Comments