vascofg / react-admin-date-inputs

Date Inputs for react-admin
MIT License
67 stars 81 forks source link

Locale gives problem in edit form. #11

Closed thecassion closed 5 years ago

thecassion commented 5 years ago


    in DateTextField
    in WithUtils(DateTextField) (created by WithStyles(WithUtils(DateTextField)))
    in WithStyles(WithUtils(DateTextField)) (created by ModalWrapper)
    in ModalWrapper (created by RenderPropsComponent)
    in RenderPropsComponent (created by withHandlers(RenderPropsComponent))
    in withHandlers(RenderPropsComponent) (created by lifecycle(withHandlers(RenderPropsComponent)))
    in lifecycle(withHandlers(RenderPropsComponent)) (created by withState(lifecycle(withHandlers(RenderPropsComponent))))
    in withState(lifecycle(withHandlers(RenderPropsComponent))) (created by BasePicker)
    in BasePicker
    in WithUtils(BasePicker) (created by DatePickerWrapper)
    in DatePickerWrapper (created by ForwardRef)
    in MuiPickersUtilsProvider (created by _makePicker)
    in div (created by _makePicker)
    in _makePicker (created by ConnectedField)
    in ConnectedField (created by Connect(ConnectedField))
    in Connect(ConnectedField) (created by Field)
    in Field (created by FormFieldView)
    in FormFieldView (created by DefaultValue)
    in DefaultValue (created by Connect(DefaultValue))
    in Connect(DefaultValue) (created by WithFormField)
    in WithFormField (at HealthCareEdit.js:56)
    in div (created by FormInput)
    in FormInput (created by WithStyles(FormInput))
    in WithStyles(FormInput) (created by FormTab)
    in span (created by FormTab)
    in FormTab (created by translate(FormTab))
    in translate(FormTab) (at HealthCareEdit.js:51)
    in Route (created by TabbedForm)
    in div (created by TabbedForm)
    in form (created by TabbedForm)
    in TabbedForm (created by WithStyles(TabbedForm))
    in WithStyles(TabbedForm) (created by Form(WithStyles(TabbedForm)))
    in Form(WithStyles(TabbedForm)) (created by Connect(Form(WithStyles(TabbedForm))))
    in Connect(Form(WithStyles(TabbedForm))) (created by ReduxForm)
    in ReduxForm (created by translate(ReduxForm))
    in translate(ReduxForm) (created by Connect(translate(ReduxForm)))
    in Connect(translate(ReduxForm)) (created by Route)
    in Route (created by withRouter(Connect(translate(ReduxForm))))
    in withRouter(Connect(translate(ReduxForm))) (at HealthCareEdit.js:50)
    in div (created by Paper)
    in Paper (created by WithStyles(Paper))
    in WithStyles(Paper) (created by Card)
    in Card (created by WithStyles(Card))
    in WithStyles(Card) (created by EditView)
    in div (created by EditView)
    in EditView (created by EditController)
    in EditController (created by translate(EditController))
    in translate(EditController) (created by Connect(translate(EditController)))
    in Connect(translate(EditController)) (created by Edit)
    in Edit (at HealthCareEdit.js:49)
    in HealthCareEdit (at App.js:75)
    in Unknown (created by WithPermissions)
    in WithPermissions (created by Connect(WithPermissions))
    in Connect(WithPermissions) (created by getContext(Connect(WithPermissions)))
    in getContext(Connect(WithPermissions)) (created by Route)
    in Route (created by Resource)
    in Switch (created by Resource)
    in Resource (created by Connect(Resource))
    in Connect(Resource) (created by AdminBuilder)
    in Route (created by RoutesWithLayout)
    in Switch (created by RoutesWithLayout)
    in RoutesWithLayout (created by Route)
    in div (created by Layout)
    in main (created by Layout)
    in div (created by Layout)
    in div (created by Layout)
    in Layout (created by WithStyles(Layout))
    in WithStyles(Layout) (created by Route)
    in Route (created by withRouter(WithStyles(Layout)))
    in withRouter(WithStyles(Layout)) (created by Connect(withRouter(WithStyles(Layout))))
    in Connect(withRouter(WithStyles(Layout))) (created by LayoutWithTheme)
    in MuiThemeProvider (created by LayoutWithTheme)
    in LayoutWithTheme (created by Route)
    in Route (created by CoreAdminRouter)
    in Switch (created by CoreAdminRouter)
    in div (created by CoreAdminRouter)
    in CoreAdminRouter (created by Connect(CoreAdminRouter))
    in Connect(CoreAdminRouter) (created by getContext(Connect(CoreAdminRouter)))
    in getContext(Connect(CoreAdminRouter)) (created by Route)
    in Route (created by CoreAdmin)
    in Switch (created by CoreAdmin)
    in Router (created by ConnectedRouter)
    in ConnectedRouter (created by CoreAdmin)
    in TranslationProvider (created by withContext(TranslationProvider))
    in withContext(TranslationProvider) (created by Connect(withContext(TranslationProvider)))
    in Connect(withContext(TranslationProvider)) (created by CoreAdmin)
    in Provider (created by CoreAdmin)
    in CoreAdmin (created by withContext(CoreAdmin))
    in withContext(CoreAdmin) (created by AdminBuilder)
    in AdminBuilder (created by _class)
    in _class (at App.js:147)
    in Unknown (at index.js:7)```
lihop commented 5 years ago

@thecassion Are you setting the locale prop and is this the error message you get (before the stack trace)?

RangeError: locale must contain localize property.

Hanno73 commented 5 years ago

RangeError: locale must contain localize property.

I have this problem and cannot see the DatePicker at all. I tried to set prop locale="en-us" or import enLocale from 'date-fns/locale/en-US'; and then locale={enLocale}

but none of it worked for me.

jeffryevans commented 5 years ago

This is problematic for us too.

vascofg commented 5 years ago

I'll be able to take a look at this next week. Meanwhile if someone has a fix feel free to submit a PR.

On Mon, 13 Aug 2018, 22:39 Jeffry Evans, notifications@github.com wrote:

This is problematic for us too.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vascofg/react-admin-date-inputs/issues/11#issuecomment-412674071, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmuSd1L6iR-tSzskB0Q90fsTHbv6ZDaks5uQfH3gaJpZM4VvLVT .

nadirberrara commented 5 years ago

Had the same issue.

I removed the tags Edit, TabbedForm and FormTab from the exemple and left the DateTimeInput (the only one I need).

const NewsEdit = props => { return ( <DateTimeInput source="startDate" label="Start date" options={{ format: 'DD/MM/YYYY HH:mm', ampm: true, clearable: true }} /> ); };

` export const MissionEdit = props => ( <Edit {...props}>

); `

Now it works for me.

Hanno73 commented 5 years ago

creating a constant with just DateTimeInput and referencing it even inside a TabbedForm and FormTab worked also for me. Thank you @nadirberrara

vascofg commented 5 years ago

I'm looking into this right now, in the meantime please use 1.0.16

vascofg commented 5 years ago

This is fixed in 1.0.20.

The problem was that the locale prop already existed in react-admin, so, when not defined in the picker component, instead of being undefined inside react-admin-date-inputs, it was receiving the value of the react-admin locale.

Anyway, please refer to the README.md for the new way to specify custom locales and util libs.