initialValues Question

0 Answers 305 Views
Form
Dominic
Top achievements
Rank 1
Iron
Dominic asked on 06 Aug 2021, 05:35 PM

I have a form and I am attempting to populate the initialValues with data returned from an API request.  

const [customer, setCustomer] = useState({});

getCustomer(props.oidc, params).then((result) => {

setCustomer(result[0]);

});

initialValues={customer}

 

I can see the data coming thru, although it does take it a second to return.  I can see the state updating, but the data does not appear to be populating in the form.  Is the data supposed to populate or am I missing something?

 

 

 

Dominic
Top achievements
Rank 1
Iron
commented on 07 Aug 2021, 10:29 PM

Never mind, I found the issue.  It was a date format problem coming from the API.
Stefan
Telerik team
commented on 09 Aug 2021, 04:57 AM

I'm glad to hear that the issue is resolved.

In general, also similar issue can occur if the initialValues are original an empty object. In those cases, we have to use this approach when the request is received:

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

No answers yet. Maybe you can help?

Tags
Form
Asked by
Dominic
Top achievements
Rank 1
Iron
Share this question
or