marmelab / react-admin

A frontend Framework for single-page applications on top of REST/GraphQL APIs, using TypeScript, React and Material Design
http://marmelab.com/react-admin
MIT License
24.77k stars 5.22k forks source link

Extra null value option when using customized SelectInput in Filter. #920

Closed ghost closed 7 years ago

ghost commented 7 years ago

customized compoent:

const MySelectInput = (props) => (
    <SelectInput  {... props}
        choices={[
        {id: true, name:"Yes"}, {id: false, name:"No"}]}
    />
)

MySelectInput.defaultProps = {
    addField: true,
    label: 'Y/N',
    source: 'my_source'
}

usage:

const MyFilter = (props) =>
<Filter {... props}>
    <MySelectInput />
</Filter>

There will be an extra blank option besides Yes and No whose value is null.

ghost commented 7 years ago

fix it by adding allowEmpty: false