# Dirty state for forms with collection properties

spaeth
1

I have the following model:

Person - String name - Set<phone> phones

My ViewModel has following filds: - Person selected - Phone selectedPhone

My View will create a form like:

<groupbox form="@id('fx') @load(vm.selected) @save(vm.selected, before='save')">


and will expose the name in a textbox and the phones on a listbox. Everytime I selected a phone I set the property selectedPhone. The phone can be edited by using another textfields on my view.

When I change the name the dirty state of my form is updated, and this is good. When I select a Phone I can see that the property selectedPhone of my viewmodel is set. But when I change the phone using the editBox bounded to selectedPhone the dirty state of my form doesn't changed.

This is expected since I'm changing the ViewModel and not the form. But what would be the way to solve this problem, since when a phone is changed, means the Person is changed too, because there are things to save?

delete retag edit

Hi, I am not I fully understand your question, from your description, you bind person name to form, but phone to VM? instead of form? any reason? If you bind phone to form, you won't have this issue, right?

( 2013-03-25 01:46:39 +0800 )edit

I'm trying to avoid the situation in which the form is marked as dirty just changing the selected phone. My goal is to have the form marked as dirty just if the user changes something within the phone object.

( 2013-03-25 09:02:12 +0800 )edit
Be the first one to answer this question!
[hide preview]