This is a migrated thread and some comments may be shown as answers.

KendoReact Form - OnSubmit

4 Answers 97 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Veteran
Anthony asked on 11 Feb 2021, 10:51 PM

 

 

I would like to expand on the example in the docs: https://www.telerik.com/kendo-react-ui/components/form/

When the form is submitted, I want to post the form data to an api end point which may "clean/update" the data and return back to client for additional input.  Once the response is returned, I want to update the corresponding fields; however, I don't see how I would be able to update the Form's fields using some like the following:

formRenderProps.onChange('city', { value: 'Philadelphia' });

Is there a better appro

4 Answers, 1 is accepted

Sort by
0
Anthony
Top achievements
Rank 1
Veteran
answered on 11 Feb 2021, 10:53 PM

I accidentally posted before I was finished.

Is there a better approach to updating the Form's state.

 

Thanks 

Anthony

0
Accepted
Stefan
Telerik team
answered on 12 Feb 2021, 05:53 AM

Hello, Anthony,

If the entire Form has to be updated/reset we can suggest checking the following example showcasing how to update the Form data:

https://www.telerik.com/kendo-react-ui-develop/components/form/advanced-scenarios/#toc-resetting-the-form-initial-state

I hope this is helpful.

Regards,
Stefan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Anthony
Top achievements
Rank 1
Veteran
answered on 16 Feb 2021, 09:56 PM

Thanks Stefan.  

I glossed by this one because I was trying to use the html control state to manage subsequent form posts.  I was focused on the example above this one.  The one you suggested is exactally what I needed 

A subtle point is the use of the key attribute on the Form.   When I didn't have it, the controls did not update with the new values.  I have used key  when mapping a collection of objects, but I have never seen it used on a From.  My understanding is it's needed by React to determine if the virtual DOM needs to update the actual DOM.

Thanks for your help.

0
xiao
Top achievements
Rank 1
answered on 02 Mar 2021, 08:26 AM
 This site is also very good
Tags
General Discussions
Asked by
Anthony
Top achievements
Rank 1
Veteran
Answers by
Anthony
Top achievements
Rank 1
Veteran
Stefan
Telerik team
xiao
Top achievements
Rank 1
Share this question
or