question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to sync form values with model data

See original GitHub issue

I’m trying to get a form to reflect the state of some model data and stay in sync with it.

For example, I want to load the form with initial values for one model, and then switch out the model and have the form update automatically to show the values from the new model.

I have tried using initialState to do this, but it never updates after the first render.

What is the correct way to load new valued into an already rendered form?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
Kaelinatorcommented, Dec 31, 2018

@grudelsud I would try passing member into the initialValues prop on the <Form>. Pass in something like member.id for the key prop in the <Form>, so long as member.id is unique for each new set of initialValue. There’s no need for a key prop to be passed into your individual inputs.

Check out this file, it might help!

1reaction
grudelsudcommented, Jan 2, 2019

that worked! thanks @Kaelinator and happy new year!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to synchronize Reactive Form value with underlined ...
Is there a way to keep original users synchronized with the form value? The problem is that users are displayed in a table...
Read more >
Keeping Data in Sync with Two-way Binding Using Ngmodel
NgModel works using these two bindings together. First, it passes the data from the component class and set data in FormControl.
Read more >
Dive into Reactive Forms. Sync values between multiple…
Today I'm going to show you a simple way to sync values in FormControl, FormGroup, and FormArray.
Read more >
Syncing Multiple Reactive Form Inputs in Angular - Cory Rylan
In this short post, we will see how we can keep as many inputs in sync with the same value using Angular's Reactive...
Read more >
Angular Forms Tutorial - 6 - Binding Data to a Model - YouTube
Angular Forms Tutorial - 6 - Binding Data to a Model ; Courses - https://learn.codevolution.dev/ ; Support UPI - https://support.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found