Skip to content
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

Schema changes aren't handled correctly #395

Closed
aantipov opened this issue May 19, 2015 · 5 comments
Closed

Schema changes aren't handled correctly #395

aantipov opened this issue May 19, 2015 · 5 comments
Milestone

Comments

@aantipov
Copy link

I have 2 schemes and 1 form definition:
Schema 1:

{   
    "type": "object",
    "required" : ["name"],
    "properties": {
        "name": { "type": "string", "title": "First Name"}
    }
}

Schema 2:

{   
    "type": "object",
    "required" : ["name"],
    "properties": {
        "name": { "type": "string", "title": "My First Name",  "enum": ['Alex', 'Peter'],}
    }
}

Form:

[ 
    {"key": 'name', "htmlClass": "col-sm-12"}
]

Schema 1 is default, so default field type is text.
When I switch to Schema 2 the field aren't changed to select, it remains the same input[type=text].

I've made some research and found out, that

  1. The field's scope has property schemaForm and its value has 2 properties form and schema
  2. schema's value corresponds to selected schema 2. That is OK.
  3. form's value contains info about the field, and this field's info contains info about the schema. But this schema info doesn't corresponds to current Schema 2, it corresponds to previous Schema 1. This is NOT OK.
@davidlgj
Copy link
Contributor

They aren't watched deeply, you need to issue a schemaFormRedraw event, see docs here for more info: https://github.com/Textalk/angular-schema-form/blob/development/docs/index.md#updating-form

@aantipov
Copy link
Author

@davidlgj It didn't help. Actually I change schema object, not just its properties, so it should work without issuing schemaFormRedraw event.

@davidlgj
Copy link
Contributor

I think I found the issue, If you supply a form definition with form objects those objects are then reused internally, for instance setting the schema attribute on them. This is what causes the problem.

So as a workaround do an angular.copy of the form definition as well when you update the schema.

I think we'll need to add one internally as well. Both to form and schema since we modify them both when needed. Shouldn't be that much of a performance issue I hope :)

@aantipov
Copy link
Author

ok, I'll try the workaround later. thanks

@Anthropic
Copy link
Member

Please re-open if you do not feel the question has been answered sufficiently.

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

No branches or pull requests

3 participants