Open bbodenmiller opened 9 years ago
Same with the deleting of form fields... try the Delete first
button on http://plnkr.co/edit/TSjSAI2E3FwJHg75Y5Hv?p=preview as well.
Hello @bbodenmiller!
Thank you for your interest in this module. However, you've forgot to mention that you are using a third-party module for list of checkboxes. Angular Input Modified is built around standard ngModel directive and strictly conforms to it's public interface. That makes it compatible with all other input plugins, that also implement the ngModel API.
I can't say exactly what the problem is, I don't have much time right now for investigation, but it looks like this issue should be looked into by developers of checklist-model
. @beradrian do you have any thoughts on this?
Thanks!
Hi @slavafomin thanks for looking into this. I am able to replicate this without a third-party module at http://plnkr.co/edit/l10QsL17GrQROVewd28x?p=preview using the Delete First
button. Any thoughts on potential solutions or areas to look into? Thanks.
Hi. Got same problem. Example from your demos with adding, deleting items from collection http://jsfiddle.net/4kxmn4Lx/
Hello! Thank you for an update on this issue. I will try to look into this on first occasion.
Is there any update on this? It would be very helpful if adding/removing an item to a collection flagged it as modified.
This module is working around ngModel
directive. In the example above, ngModel
points not to the collection, but to the element of the collection, therefore it watches the element for changes and not the collection itself. You should be able to watch the collection manually using $scope.$watch
function. I'm not sure it should be handled by this module.
However, if you have ideas of how it could be implemented, I'm open for discussions ;)
We run into the similar issue. Then, we found out that adding/deleting an ngModel after a form has been initialized won't trigger the inputModified.formChanged event. Is it a way we could fire the event? Will it solve the problem and keep the features of this package?
We have the same issue. Would be nice if you add support for dynamic fields.
We're having a similar issue. I've put together a plunker to demonstrate the issue in the simplest form possible.
1. Adding new elements to a form does not mark it modified
I understand that when new elements are added, the masterValue
of that input's ngModel is set to its initial value . By that logic, that input is indeed not in a modified state when it first appears, and by extension, the form is not modified either.
2. Removing existing elements does not update the modified flag.
For example, let's say there are two inputs in a form and one of them is modified. At this point, the form's modified
flag is true
. Removing the modified input does not cause the form's modified
flag to become false
- however, this may or may not be desirable in most use cases.
-- It is often the case that an input is added because of a change to a complex object. Conversely, form elements may be deleted when a change happens to that same object. The form's modified state is mostly likely being used as a proxy for that object's modified state.
What that is the use pattern, it is desirable to set the form's modified
flag to true if that form no longer has the same inputs that it started off with. Perhaps this behaviour could be toggled on my adding a flag to the ngForm
. What do you think?
Thank you everyone for pointing out your issues. However, I see different use cases and different problems mentioned. Could someone reduce everything being said here to a concrete proposition and/or algorithm?
The module wasn't designed for dynamic forms initially, so there could be problems with it. Right now we have the following rules:
1). Form's modification state is controlled by modification state of all children forms and models.
2). Model's modification state is determined by it's current value and it's equality to the master value.
3). The master value is determined when control is created or when it's manually marked as pristine
.
So the proposition should take into account above rules. Especially, if you have cases where the rules are not respected for some reason (we should consider such cases as bugs and fix them as a first priority).
I'm attempting to add new form fields (checkboxes) to a form using
ngRepeat
and have this mark the form as modified. A bit hard to explain but try selecting theAdd new
at http://plnkr.co/edit/TSjSAI2E3FwJHg75Y5Hv?p=preview and see that the form is not marked as modified.Looks related to #12.