Skip to content

2 forms cannot exist at same time #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stalsma opened this issue Oct 20, 2017 · 5 comments
Open

2 forms cannot exist at same time #120

stalsma opened this issue Oct 20, 2017 · 5 comments
Labels

Comments

@stalsma
Copy link
Contributor

stalsma commented Oct 20, 2017

I found this by accident; no real use case. But it is unexpected. The second form simply overwrites the first one. Is the service somehow stateful, and the data from the second instance gets stored in the service, overwriting the configuration of the first instance?

Here's a simple component to reproduce:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'simple-component',
  template: `
    <json-schema-form [data]="jsonFormObject1"
                      [options]="jsonFormOptions"></json-schema-form>

    <json-schema-form [data]="jsonFormObject2"
                      [options]="jsonFormOptions"></json-schema-form>

  `
})
export class SimpleComponent implements OnInit {

  jsonFormObject1: object = {
    data: {
      username: 'JoeSmith',
      password: '1234'
    }
  };

  jsonFormObject2: object = {
    first_name: 'Jane',
    last_name: 'Doe',
  };

  constructor() { }

  ngOnInit() {
  }

  jsonFormOptions: any = {
    addSubmit: true, // Add a submit button if layout does not have one
    loadExternalAssets: true, // Load external css and JavaScript for frameworks
    formDefaults: { feedback: true }, // Show inline feedback icons
    debug: false,
    returnEmptyFields: false,
  };
}
@qid14
Copy link

qid14 commented Oct 21, 2017

I met the same issue, weird.

@qid14
Copy link

qid14 commented Oct 25, 2017

I found the old version 0.5.0-alpha.2 is OK, above versions fail. While the layout is different in this version.

@dschnelldavis
Copy link
Owner

That's odd.

OK, since it was working before, I've changed this from "enhancement" back to "bug."

I don't know what's causing it, but I'll try to figure it out.

@ofirpar
Copy link

ofirpar commented Nov 8, 2017

Maybe add the providers from module to the json-schema Component
This way, each service will have its own instance for each json-schema component and manage data for each instance individually.

@ChrisButtermelon
Copy link

@dschnelldavis any update on a fix for this bug? i am facing the same issue. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants