0

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?

Moustafa Elkady
  • 670
  • 1
  • 7
  • 17

2 Answers2

2

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)
Alexey
  • 601
  • 7
  • 17
1

If you want to customize the inputs behaviors, you'll have to write your own: documentation

Gildas Garcia
  • 6,966
  • 3
  • 15
  • 29