-
Notifications
You must be signed in to change notification settings - Fork 653
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
Don't modify form or schema #407
Comments
What would you do if the user updates theirs, re-process? What if they have a decorator that makes changes? Just thinking out loud... |
Currently we re-process when a ordinary watch changes it, i.e. the schema object instance or form array is changed (ordinary This probably needs to be optional, since in certain cases you can change part of your form, ex. |
Perhaps this is a related issue. I have created a form editor. I noticed an odd behavior. I store the form def and form schema in a subkey of a larger JSON. If I specify the form and schema, for some reason any form element keys are changed from say key: "description" to key: ["description"]. So I thought "okay let's clone it" and use JQuery's extend to create a deep copy. Unfortunately only the initial extend causes the form display to update. Subsequent changes do not cause the form to be redrawn. As a result added or changed fields are not reflected in the "preview" where I display a hidden div to render the form being created. Any suggestions or clues? |
@rayhooker Yes this is the exact same problem. Schema Form messes with the form definition internally, massaging it in to a "canonical" form. Redraws of form is only done if the instance of the object changes, not just a property. See https://github.com/Textalk/angular-schema-form/blob/development/docs/index.md#updating-form So the solution for you is to issue a |
I noticed that this also affects the way the 'key'-value gets stored. I had a couple of keys containing '.' (dots). "model": {
"Field.SystemSettingExchange.ExchangeEnabled": true,
//etc... I add these exact same keys to the form like this: $scope.form.push({
'key': fieldEntry.key,
'type': fieldEntry.type
}); and they come out in a array, which breaks the coupling with the model, among other things: "form": [
{
"key": [
"Field",
"SystemSettingExchange",
"ExchangeEnabled"
]
},
//etc... |
That's great to hear. I've changed my backend to remove the dots so I can test my use-case easily if this is done. Let me know if I can help out. |
Was this fixed? I am having the same problem. I am building dynamic forms and I need my form objects left unchanged so I can reproduce forms at a later date. Schema Form keeps changing my keys to arrays whenever I render. |
@tjones0808 I just had a quick look and I would expect if you search in the compiled file for initialForm and find the line: I will look at adding it to the next release. Please let me know if that was all that was required! To be honest it seems too easy, I suspect I am missing something. |
Related to #395
Incoming form definition objects are reused and in case of some defaults the schema might be changed as well. We should make a copy to use internally.
The text was updated successfully, but these errors were encountered: