Search code examples
admin-on-rest

How can i add onChange on DateInput component


i'm new with admin-on-rest. I want to add onChange event on

<DateInput source="day_date" />

how can i do that? i tried

<DateInput source="day_date" onChange={(v) => {console.log(v)}}/>

and it seems not working.

any ideas?


Solution

  • DateInput base on http://www.material-ui.com/#/components/date-picker . it seems onChange take 2 params first of them always null(undefined). but you can search source code of this component in your project node_modules/admin-on-rest/src/mui/input/DateInput.js you need get 2 parameter for Date. so just try this:

    <DateInput source="start_date" onChange={(v, d) => {console.log(v, d)}}/>
    

    in my browser I can see:

    Object {preventDefault: function} Thu May 25 2017 00:00:00 GMT+0300 (MSK)