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 do you keep track of form model changes with one way binding

See original GitHub issue

I am trying to do an edit operation. Eg. I load the data for the form, set it to the model and then would like to compare the original values and the new values in OnFinish(EditContext editContext) callback using the editContext.Model (new values) when the form submitted is valid? I was thinking that I would use one way binding on the FormItem e.g.

<FormItem Label="Note"> <Input Value="@context.Note" /> </FormItem>

where my original model is loaded from the DB and set in the form as the “model” and the new updated values are in the EditContext in the OnFinish callback but I’m getting the following exception when I try one way binding. I’m not sure if this is correct

"Invalid OperationException: "Please use @bind-Value (or @bind-Values for selected components) in the control with generic type 'System.String'

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ElderJamescommented, Feb 19, 2023

For the label you can set the FormItem.Label directly.

0reactions
vincejairamcommented, Feb 18, 2023

Didn’t even realize, I didn’t have the latest release 😦. I had to fix some breaking changes e.g RowTemplate was Changed to ColumnDefinitions … anyway I was able to change it to oneway binding now but when the OnFinish(EditContext editContext) callback is called the editContext.Model (does NOT contain new values) from the form.

I also noticed that the label that was shown before when two binding was in place from my c# model with description is not shown anymore with oneway binding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular ngModel one-way binding
(*)Angular check the change of the model, but the model don't change, so, has no way to show the "same value".
Read more >
Keeping Track of Form Changes In Angular
One of the benefits of using the NgModel directive on a control, besides binding, is that it tracks the state of that control....
Read more >
One-way and Two-way Data Binding in Angular
From View to Component​​ One-way data binding from view to the component can be achieved by using the event binding technique.
Read more >
[AskJS] Why is one-way binding better than two-way?
The one place where two-way binding is unambiguously better for all but edge cases is binding form fields to a backing model object....
Read more >
How To Bind Any Component to Data in React: One-Way ...
This article will discuss data binding, types, how to utilize useState and useRef to bind data in React and more.
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