formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.23k stars 406 forks source link

angular-formly is changing values on another tab when submit #764

Closed mokipedia closed 6 years ago

mokipedia commented 6 years ago

Hi there,

I do have kind of a big problem and as it involves tabs I am lost at how I can give you a plunkr example: We have quite a big application, that makes heavy use of angular-formly to create dynamic forms. It is based on Angular 1.5.8 and Bootstrap 3. We are relying heavily on components and tried to follow Todd Mottos style guide.

Now the problem (or bug?):

I have a component that holds a form, lets call it formComponent.

module

var formComponent = {
  template: '...<form name="$ctrl.form" on-submit="$ctrl.save();"> <formly-form ... form="$ctrl.form" model="$ctrl.formModel"> <button type="submit">save</button> </form></formlyForm>',
  controller: ...,
}

The problem with this is: When several tabs are open with the same application, both show a formly-form and you click the save button, all tabs in the background will get reloaded and GET-parameters are injected before the hashbang. this looks like this:

http://localhost:3000/?%24ctrl.formBlueprintForm_input_label_0=Test&%24ctrl.formBlueprintForm_input_key_1=test#/admin/blueprint/form/edit/2

this parameters are the form fields of the tab they appear in (so each tab has different params when showing different forms), thought the value of the first field is always the one from the tab you clicked. Now, if you change the button from type=submit to button and give it a ng-click, the parameters in the url are not injected. however the form fields itself get synchronized (or at least the first one does like the parameters in the url).

That is absolutely not intended behavior and I have no clue how to fix it. I do not know if it is a component based problem, but thought the info might help. it does not seem to be related to the save function as I commented that out with no effect (other than the backend call not happening).

I also tried to search for this issue or other mentioning of simmilar issues, though to no avail.

mokipedia commented 6 years ago

fixed, unrelated to formly. sorry