{"action":"created","issue":{"url":"https://api.github.com/repos/formly-js/ngx-formly/issues/758","repository_url":"https://api.github.com/repos/formly-js/ngx-formly","labels_url":"https://api.github.com/repos/formly-js/ngx-formly/issues/758/labels{/name}","comments_url":"https://api.github.com/repos/formly-js/ngx-formly/issues/758/comments","events_url":"https://api.github.com/repos/formly-js/ngx-formly/issues/758/events","html_url":"https://github.com/formly-js/ngx-formly/issues/758","id":300561947,"number":758,"title":"[SUPPORT] nested group access to parent model and validity using expressionProperties","user":{"login":"jogelin","id":954509,"avatar_url":"https://avatars2.githubusercontent.com/u/954509?v=4","gravatar_id":"","url":"https://api.github.com/users/jogelin","html_url":"https://github.com/jogelin","followers_url":"https://api.github.com/users/jogelin/followers","following_url":"https://api.github.com/users/jogelin/following{/other_user}","gists_url":"https://api.github.com/users/jogelin/gists{/gist_id}","starred_url":"https://api.github.com/users/jogelin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jogelin/subscriptions","organizations_url":"https://api.github.com/users/jogelin/orgs","repos_url":"https://api.github.com/users/jogelin/repos","events_url":"https://api.github.com/users/jogelin/events{/privacy}","received_events_url":"https://api.github.com/users/jogelin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-27T09:56:58Z","updated_at":"2018-02-28T08:33:30Z","closed_at":null,"author_association":"NONE","body":"**I'm submitting a ...**  (check one with \"x\")\r\n```\r\n[ ] bug report => search github for a similar issue or PR before submitting\r\n[X] feature request\r\n[X] support request\r\n```\r\n\r\n**Current behavior**\r\nNA\r\n\r\n**Expected behavior**\r\nBased on a form description like this: \r\n```\r\n[\r\n    {\r\n      key: 'reference',\r\n      type: 'input',\r\n      templateOptions: {\r\n        label: 'Reference',\r\n        required: true\r\n      }\r\n    },\r\n    {\r\n      key: 'persons',\r\n      type: 'person-search-field',\r\n      // TODO: here the model is an array, how can I access to the reference value\r\n      expressionProperties: {\r\n        'templateOptions.reference': 'model.reference',\r\n        'templateOptions.referenceIsValid': 'form.reference.valid'\r\n      },\r\n      fieldArray: {\r\n        templateOptions: {\r\n          label: 'Search Person'\r\n        }\r\n      }\r\n    } \r\n  ]\r\n```\r\n\r\nI would like to:\r\n* provide the value of the reference field to the type `person-search-field` (this value is needed to search a person)\r\n* disable the type `person-search-field` if the field `reference`  is not valid (really like formControl.valid)\r\n\r\nI based my implementation of `person-search-field` on the `repeat-field` type but I am using a separate form to search for a person and then, I add it to the `formArray`. Is it a good way of doing that ?\r\n\r\n**Minimal reproduction of the problem with instructions**\r\nYou can find the example on [StackBlitz](https://stackblitz.com/edit/angular-formly-template-rc-32?file=app%2Fapp.component.ts)\r\n\r\nThx in advance, this lib is very useful. \r\n\r\nBy the way, I am beginner using formly and I think it is very useful to have a lot of examples. Are you open for PR that add example in your doc ? For example \"Nested Searching Type\"...\r\n"},"comment":{"url":"https://api.github.com/repos/formly-js/ngx-formly/issues/comments/369159745","html_url":"https://github.com/formly-js/ngx-formly/issues/758#issuecomment-369159745","issue_url":"https://api.github.com/repos/formly-js/ngx-formly/issues/758","id":369159745,"user":{"login":"jogelin","id":954509,"avatar_url":"https://avatars2.githubusercontent.com/u/954509?v=4","gravatar_id":"","url":"https://api.github.com/users/jogelin","html_url":"https://github.com/jogelin","followers_url":"https://api.github.com/users/jogelin/followers","following_url":"https://api.github.com/users/jogelin/following{/other_user}","gists_url":"https://api.github.com/users/jogelin/gists{/gist_id}","starred_url":"https://api.github.com/users/jogelin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jogelin/subscriptions","organizations_url":"https://api.github.com/users/jogelin/orgs","repos_url":"https://api.github.com/users/jogelin/repos","events_url":"https://api.github.com/users/jogelin/events{/privacy}","received_events_url":"https://api.github.com/users/jogelin/received_events","type":"User","site_admin":false},"created_at":"2018-02-28T08:33:30Z","updated_at":"2018-02-28T08:33:30Z","author_association":"NONE","body":"Good ;), I'll try to add more specifics example when I solve a scenario.\r\n\r\nBut first, I need to solve this one ;)\r\n\r\nFor the moment, I did an ugly thing in my custom type like:\r\n\r\n```\r\nthis.form\r\n      .get(this.to.referenceKey)\r\n      .statusChanges.pipe(distinctUntilChanged())\r\n      .subscribe(status => {\r\n        if (status === 'VALID') {\r\n          this.enable();\r\n        } else {\r\n          this.disable();\r\n        }\r\n        this.cdRef.detectChanges();\r\n      });\r\n```\r\n\r\nBut this create a string link between this type and my form structure which I don't like..."}}
{"actor":{"display_login":"jogelin"}}