redux-form-material-ui
redux-form-material-ui copied to clipboard
[SelectField][DatePicker] - No value displayed after Initialize From State
Hi, First of all, I would like to thank you for your hard work and for sharing it with all of us.
I'm trying to use SelectField and DatePicker in my form. It works very well when I want to create a new form, but when I want to edit it (Initialize From State) doesn't populate the fields. I have this problem only with SelectField and DatePicker, the other fields are working fine. Can you help me?
import { SelectField, DatePicker } from 'redux-form-material-ui'
import { MenuItem } from 'material-ui'
<Field
name='clientName'
component={SelectField}
floatingLabelText={I18n.t('form.company.title')}
hintText={I18n.t('form.company.hint')}
fullWidth
floatingLabelFixed
>
{companiesList.map(company => (<MenuItem key={company.id} value={company} primaryText={company.text} />))}
</Field>
<Field
name='orderDate'
component={DatePicker}
floatingLabelText={I18n.t('form.orderDate.title')}
hintText={I18n.t('form.orderDate.hint')}
DateTimeFormat={DateTimeFormat}
locale='ro'
mode='landscape'
container='dialog'
floatingLabelFixed
fullWidth
/>
companiesList: [
{ id: 101, text: 'Google'},
{ id: 102, text: 'Amazon'},
{ id: 103, text: 'Microsoft'}
],
My state looks like:
form: {
order: {
values: {
clientName: {
id: 101,
text: 'Google'
},
orderDate: '2017-11-05T06:05:25.912Z'
}
}
}
I'm using:
"redux-form": "^7.1.2",
"redux-form-material-ui": "^4.3",
AFAIK, orderDate
should be an object Date
.