{"action":"opened","issue":{"url":"https://api.github.com/repos/signalpoint/DrupalGap/issues/465","labels_url":"https://api.github.com/repos/signalpoint/DrupalGap/issues/465/labels{/name}","comments_url":"https://api.github.com/repos/signalpoint/DrupalGap/issues/465/comments","events_url":"https://api.github.com/repos/signalpoint/DrupalGap/issues/465/events","html_url":"https://github.com/signalpoint/DrupalGap/issues/465","id":56932781,"number":465,"title":"A field's form element item's children is not set by the time hook_form_alter() is invoked","user":{"login":"signalpoint","id":671140,"avatar_url":"https://avatars.githubusercontent.com/u/671140?v=3","gravatar_id":"","url":"https://api.github.com/users/signalpoint","html_url":"https://github.com/signalpoint","followers_url":"https://api.github.com/users/signalpoint/followers","following_url":"https://api.github.com/users/signalpoint/following{/other_user}","gists_url":"https://api.github.com/users/signalpoint/gists{/gist_id}","starred_url":"https://api.github.com/users/signalpoint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/signalpoint/subscriptions","organizations_url":"https://api.github.com/users/signalpoint/orgs","repos_url":"https://api.github.com/users/signalpoint/repos","events_url":"https://api.github.com/users/signalpoint/events{/privacy}","received_events_url":"https://api.github.com/users/signalpoint/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/signalpoint/DrupalGap/labels/Improvement","name":"Improvement","color":"336633"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-08T00:38:22Z","updated_at":"2015-02-08T00:38:22Z","closed_at":null,"body":"When using hook_form_alter(), you can't directly push to an item's children array, because it might not be created yet. It seems children may not be instantiated until _drupalgap_form_render_element() is called, which means we should move it's instantiation up into the form builder assembly.\r\n\r\nIf you need to modify the children via hook_form_alter(), just create the children array first, e.g.:\r\n\r\n```\r\nif (!form.elements['field_foo']['und'][0].children) {\r\n  form.elements['field_foo']['und'][0].children = [];\r\n}\r\n```"}}