4

I am trying to pass a callback so I can use ImageInput to save the files/images before the form is submitted..I am curious how this can be done.. onDrop, onChange etc.. don't do anything. Thanks!

const callback = () => { console.log("callback"); }
[..]
<ImageInput source="pictures" accept="image/*" onDrop={callback}>
  <ImageField source="src" title="title" />
</ImageInput>
Michail Michailidis
  • 11,792
  • 6
  • 63
  • 106
  • 1
    You'll have to implement your own custom input for that. Those props are already used internally. See https://stackoverflow.com/questions/46377179/admin-on-rest-send-extra-params-to-rest-call – Gildas Garcia Sep 28 '17 at 06:53
  • Thanks @Gildas any reason why there wasn't a similar to onDrop prop exposed on ImageInput so someone can pass a callbacck? OnDelete would be nice too – Michail Michailidis Sep 29 '17 at 00:27
  • Because we wanted to keep it the simplest possible – Gildas Garcia Sep 29 '17 at 06:57

1 Answers1

4

You have to include the onDrop event inside options properties.

const callback = () => { console.log("callback"); }
[..]
<ImageInput source="pictures" accept="image/*" options={{onDrop:callback}}>
  <ImageField source="src" title="title" />
</ImageInput>
Mohamed Nizar
  • 780
  • 9
  • 30