Changing multiple form field values based on dropdown value

1 Answer 370 Views
Form
Bernd
Top achievements
Rank 5
Bronze
Bronze
Bronze
Bernd asked on 17 Dec 2021, 04:03 PM

I have a form with a dropdown. Based on what gets chosen in the dropdown, multiple fields in the form should get changed. Code:

https://stackblitz.com/edit/react-ts-m3qyz2?file=index.tsx

This works perfectly but the code is quite messy (see lines 93 - 115). I would prefer to call the onChange handler external like in the lines I have commented out (onDataTypeChange). But this doesn't work because there I don't have access to the formRenderProps.onChange method. How could I achive this?

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Filip
Telerik team
answered on 21 Dec 2021, 11:41 AM

Hello, Bernd,

The provided stackblitz example did not run, and because of that I was not able to test the component and logic, however, it is possible to pass the formRenderProps.onChange to the onChange event handler like this:

onChange={​​(е) => onDataTypeChange(е, formRenderProps.onChange)}​​

I hope this helps.

Regards, Filip Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Bernd
Top achievements
Rank 5
Bronze
Bronze
Bronze
commented on 21 Dec 2021, 01:18 PM

Oh my god... sometimes it's so easy. :-) Thanks!

 

Tags
Form
Asked by
Bernd
Top achievements
Rank 5
Bronze
Bronze
Bronze
Answers by
Filip
Telerik team
Share this question
or