{"action":"closed","issue":{"url":"https://api.github.com/repos/formly-js/ngx-formly/issues/980","repository_url":"https://api.github.com/repos/formly-js/ngx-formly","labels_url":"https://api.github.com/repos/formly-js/ngx-formly/issues/980/labels{/name}","comments_url":"https://api.github.com/repos/formly-js/ngx-formly/issues/980/comments","events_url":"https://api.github.com/repos/formly-js/ngx-formly/issues/980/events","html_url":"https://github.com/formly-js/ngx-formly/issues/980","id":330038176,"node_id":"MDU6SXNzdWUzMzAwMzgxNzY=","number":980,"title":"Issue with form generation on Angular 5 and forms loaded via JSON","user":{"login":"darlontrofy","id":24609322,"node_id":"MDQ6VXNlcjI0NjA5MzIy","avatar_url":"https://avatars3.githubusercontent.com/u/24609322?v=4","gravatar_id":"","url":"https://api.github.com/users/darlontrofy","html_url":"https://github.com/darlontrofy","followers_url":"https://api.github.com/users/darlontrofy/followers","following_url":"https://api.github.com/users/darlontrofy/following{/other_user}","gists_url":"https://api.github.com/users/darlontrofy/gists{/gist_id}","starred_url":"https://api.github.com/users/darlontrofy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darlontrofy/subscriptions","organizations_url":"https://api.github.com/users/darlontrofy/orgs","repos_url":"https://api.github.com/users/darlontrofy/repos","events_url":"https://api.github.com/users/darlontrofy/events{/privacy}","received_events_url":"https://api.github.com/users/darlontrofy/received_events","type":"User","site_admin":false},"labels":[{"id":197471517,"node_id":"MDU6TGFiZWwxOTc0NzE1MTc=","url":"https://api.github.com/repos/formly-js/ngx-formly/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-06T21:24:01Z","updated_at":"2018-06-08T14:36:45Z","closed_at":"2018-06-08T14:36:45Z","author_association":"NONE","body":"<!--\r\nIF YOU DON'T FILL OUT THE FOLLOWING INFORMATION WE MIGHT CLOSE YOUR ISSUE WITHOUT INVESTIGATING\r\n-->\r\n\r\n**I'm submitting a ...**  (check one with \"x\")\r\n```\r\n[X ] bug report => search github for a similar issue or PR before submitting\r\n[ ] feature request\r\n[ ] support request\r\n```\r\n\r\n**Current behavior**\r\n<!-- Describe how the bug manifests. -->\r\nThe form is not generated and errors out with errors printed on the console.\r\n**Expected behavior**\r\n<!-- Describe what the behavior would be without the bug. -->\r\n\r\n**Minimal reproduction of the problem with instructions**\r\n<!--\r\nIf the current behavior is a bug or you can illustrate your feature request better with an example,\r\nplease provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via\r\nhttps://stackblitz.com or similar.\r\nThe line to assign (((field)).model = model;) errors out when you have an empty model ({}), and loading the fields via json. \r\n\r\n <form [formGroup]=\"form\">\r\n          <formly-form [model]=\"modela\" [fields]=\"fields\" [options]=\"options\" [form]=\"form\">           \r\n          </formly-form>\r\n        </form>\r\n\r\nfunction assignModelToFields(fields, model) {\r\n    fields.forEach(function (field, index) {\r\n        if (!isUndefined(field.defaultValue) && isUndefined(getValueForKey(model, field.key))) {\r\n            assignModelValue(model, field.key, field.defaultValue);\r\n        }\r\n        ((field)).model = model;\r\n        if (field.key && (field.fieldGroup || field.fieldArray)) {\r\n            ((field)).model = getFieldModel(model, field, true);\r\n        }\r\n        if (field.fieldGroup) {\r\n            assignModelToFields(field.fieldGroup, field.model);\r\n        }\r\n    });\r\n}\r\n\r\nYou get the error below:\r\nOrderComponent.html:33 ERROR TypeError: Cannot add property model, object is not extensible\r\n    at eval (ngx-formly-core.js:88)\r\n    at Array.forEach (<anonymous>)\r\n    at assignModelToFields (ngx-formly-core.js:84)\r\n    at FormlyFormBuilder.buildForm (ngx-formly-core.js:500)\r\n    at FormlyForm.ngOnChanges (ngx-formly-core.js:822)\r\n    at checkAndUpdateDirectiveInline (core.js:12396)\r\n    at checkAndUpdateNodeInline (core.js:13927)\r\n    at checkAndUpdateNode (core.js:13870)\r\n    at debugCheckAndUpdateNode (core.js:14763)\r\n    at debugCheckDirectivesFn (core.js:14704)\r\n\r\nUI Bootstrap: https://stackblitz.com/edit/ngx-formly-ui-bootstrap\r\nUI Material: https://stackblitz.com/edit/ngx-formly-ui-material\r\n-->\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n<!-- Describe the motivation or the concrete use case -->\r\n\r\n**Please tell us about your environment:**\r\n<!-- Operating system, IDE, package manager, HTTP server, ... -->\r\nVS CODE\r\n* **Angular version:** 2.0.X\r\n<!-- Check whether this is still an issue in the most recent Angular version -->\r\n5\r\n* **Browser:** [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]\r\n<!-- All browsers where this could be reproduced -->\r\nChrome\r\n* **Language:** [all | TypeScript X.X | ES6/7 | ES5]\r\nTypescript\r\n* **Node (for AoT issues):** `node --version` =\r\n"}}
{"actor":{"display_login":"darlontrofy"}}