{"action":"opened","issue":{"url":"https://api.github.com/repos/marmelab/react-admin/issues/2527","repository_url":"https://api.github.com/repos/marmelab/react-admin","labels_url":"https://api.github.com/repos/marmelab/react-admin/issues/2527/labels{/name}","comments_url":"https://api.github.com/repos/marmelab/react-admin/issues/2527/comments","events_url":"https://api.github.com/repos/marmelab/react-admin/issues/2527/events","html_url":"https://github.com/marmelab/react-admin/issues/2527","id":380260403,"node_id":"MDU6SXNzdWUzODAyNjA0MDM=","number":2527,"title":"CheckboxGroupInput in Form : value.find is not a function error","user":{"login":"pichichi40","id":6481025,"node_id":"MDQ6VXNlcjY0ODEwMjU=","avatar_url":"https://avatars3.githubusercontent.com/u/6481025?v=4","gravatar_id":"","url":"https://api.github.com/users/pichichi40","html_url":"https://github.com/pichichi40","followers_url":"https://api.github.com/users/pichichi40/followers","following_url":"https://api.github.com/users/pichichi40/following{/other_user}","gists_url":"https://api.github.com/users/pichichi40/gists{/gist_id}","starred_url":"https://api.github.com/users/pichichi40/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pichichi40/subscriptions","organizations_url":"https://api.github.com/users/pichichi40/orgs","repos_url":"https://api.github.com/users/pichichi40/repos","events_url":"https://api.github.com/users/pichichi40/events{/privacy}","received_events_url":"https://api.github.com/users/pichichi40/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-13T14:46:36Z","updated_at":"2018-11-13T14:46:36Z","closed_at":null,"author_association":"NONE","body":"**What you were expecting:**\r\nWhen CheckboxGroupInput \"source\" attribute value is not in data model\r\n\r\n**What happened instead:**\r\nTypeError\r\nvalue.find is not a function\r\n\r\n**Steps to reproduce:**\r\ndata model :\r\n```\r\nexport default {\r\n  posts: [\r\n    {\r\n      id: 1,\r\n      title:\r\n        \"Accusantium qui nihil voluptatum quia voluptas maxime ab similique\",\r\n      notifications: [12, 31, 42]\r\n    }\r\n  ]\r\n};\r\n```\r\n\r\ncomponent :\r\n```\r\nexport const PostEdit = props => (\r\n  <Edit title={<PostTitle />} {...props}>\r\n    <TabbedForm defaultValue={{ average_note: 0 }}>\r\n      <FormTab label=\"post.form.summary\">\r\n        <DisabledInput source=\"id\" />\r\n        <TextInput source=\"title\" />\r\n\r\n        <CheckboxGroupInput\r\n          source=\"notifications\"\r\n          choices={[\r\n            { id: 12, name: \"Ray Hakt\" },\r\n            { id: 31, name: \"Ann Gullar\" },\r\n            { id: 42, name: \"Sean Phonee\" }\r\n          ]}\r\n        />\r\n        <CheckboxGroupInput\r\n          source=\"notifications2\"\r\n          choices={[\r\n            { id: 12, name: \"Ray Hakt\" },\r\n            { id: 31, name: \"Ann Gullar\" },\r\n            { id: 42, name: \"Sean Phonee\" }\r\n          ]}\r\n        />\r\n      </FormTab>\r\n    </TabbedForm>\r\n  </Edit>\r\n);\r\n```\r\n\r\n**Related code:**\r\nCodeSandbox (https://codesandbox.io/s/4wz63x1jmx)\r\n\r\n\r\n**Temporarily fixed with the following code in node_modules\\ra-ui-materialui\\esm\\input\\CheckboxGroupInput.js :**\r\nline 34 add :\r\n`\r\nimport _toConsumableArray from 'babel-runtime/helpers/toConsumableArray';\r\n`\r\n\r\nline 138 (approximately) replace _onChange(value.concat([newValue]));_ :\r\n```\r\n_this.handleCheck = function (event, isChecked) {\r\n            var _a = _this.props.input, value = _a.value, onChange = _a.onChange;\r\n            var newValue;\r\n            try {\r\n                // try to convert string value to number, e.g. '123'\r\n                newValue = JSON.parse(event.target.value);\r\n            }\r\n            catch (e) {\r\n                // impossible to convert value, e.g. 'abc'\r\n                newValue = event.target.value;\r\n            }\r\n            if (isChecked) {\r\n              //FIXED HERE\r\n              onChange([].concat(_toConsumableArray(value), [newValue]));\r\n              //onChange(value.concat([newValue]));\r\n            }\r\n            else {\r\n                onChange(value.filter(function (v) { return v != newValue; }));\r\n            }\r\n        };\r\n```\r\n\r\n**Environment**\r\n* React-admin version: 2.4.2\r\n* React version: 16.3.2, 16.4.2 (no tests on other versions)\r\n* Stack trace (in case of a JS error): \r\n\r\nTypeError: value.find is not a function\r\n\r\n    in CheckboxGroupInput (created by WithStyles(CheckboxGroupInput))\r\n    in WithStyles(CheckboxGroupInput) (created by Context.Consumer)\r\n    in translate(WithStyles(CheckboxGroupInput)) (created by ConnectedField)\r\n    in ConnectedField (created by Connect(ConnectedField))\r\n    in Connect(ConnectedField) (created by Field)\r\n    in Field (created by FormFieldView)\r\n    in FormFieldView (created by DefaultValue)\r\n    in DefaultValue (created by Connect(DefaultValue))\r\n    in Connect(DefaultValue) (created by WithFormField)\r\n    in WithFormField (at ProfilEdit.js:159)\r\n    in div (created by FormInput)\r\n    in FormInput (created by WithStyles(FormInput))\r\n    in WithStyles(FormInput) (created by FormTab)\r\n    in span (created by FormTab)\r\n    in FormTab (created by Context.Consumer)\r\n    in translate(FormTab) (at ProfilEdit.js:129)\r\n    in Route (created by TabbedForm)\r\n    in div (created by CardContent)\r\n    in CardContent (created by WithStyles(CardContent))\r\n    in WithStyles(CardContent) (created by CardContentInner)\r\n    in CardContentInner (created by WithStyles(CardContentInner))\r\n    in WithStyles(CardContentInner) (created by TabbedForm)\r\n    in form (created by TabbedForm)\r\n    in TabbedForm (created by WithStyles(TabbedForm))\r\n    in WithStyles(TabbedForm) (created by Form(WithStyles(TabbedForm)))\r\n    in Form(WithStyles(TabbedForm)) (created by Connect(Form(WithStyles(TabbedForm))))\r\n    in Connect(Form(WithStyles(TabbedForm))) (created by ReduxForm)\r\n    in ReduxForm (created by Context.Consumer)\r\n    in translate(ReduxForm) (created by Connect(translate(ReduxForm)))\r\n    in Connect(translate(ReduxForm)) (created by Route)\r\n    in Route (created by withRouter(Connect(translate(ReduxForm))))\r\n    in withRouter(Connect(translate(ReduxForm))) (at ProfilEdit.js:121)\r\n    in div (created by Paper)\r\n    in Paper (created by WithStyles(Paper))\r\n    in WithStyles(Paper) (created by Card)\r\n    in Card (created by WithStyles(Card))\r\n    in WithStyles(Card) (created by EditView)\r\n    in div (created by EditView)\r\n    in EditView (created by EditController)\r\n    in EditController (created by Context.Consumer)\r\n    in translate(EditController) (created by Connect(translate(EditController)))\r\n    in Connect(translate(EditController)) (created by Edit)\r\n    in Edit (created by WithStyles(Edit))\r\n    in WithStyles(Edit) (at ProfilEdit.js:120)\r\n    in div (at ProfilEdit.js:119)\r\n    in ProfilEdit (created by WithStyles(ProfilEdit))\r\n    in WithStyles(ProfilEdit) (created by Context.Consumer)\r\n    in translate(WithStyles(ProfilEdit)) (created by Connect(translate(WithStyles(ProfilEdit))))\r\n    in Connect(translate(WithStyles(ProfilEdit))) (created by WithPermissions)\r\n    in WithPermissions (created by Connect(WithPermissions))\r\n    in Connect(WithPermissions) (created by getContext(Connect(WithPermissions)))\r\n    in getContext(Connect(WithPermissions)) (created by Route)\r\n    in Route (created by Resource)\r\n    in Switch (created by Resource)\r\n    in Resource (created by Connect(Resource))\r\n    in Connect(Resource) (at App.js:285)\r\n    in Route (created by RoutesWithLayout)\r\n    in Switch (created by RoutesWithLayout)\r\n    in RoutesWithLayout (created by Route)\r\n    in div (created by Layout)\r\n    in main (created by Layout)\r\n    in div (created by Layout)\r\n    in div (created by Layout)\r\n    in Layout (created by WithStyles(Layout))\r\n    in WithStyles(Layout) (created by Route)\r\n    in Route (created by withRouter(WithStyles(Layout)))\r\n    in withRouter(WithStyles(Layout)) (created by Connect(withRouter(WithStyles(Layout))))\r\n    in Connect(withRouter(WithStyles(Layout))) (created by LayoutWithTheme)\r\n    in MuiThemeProvider (created by LayoutWithTheme)\r\n    in LayoutWithTheme (created by Connect(LayoutWithTheme))\r\n    in Connect(LayoutWithTheme) (at App.js:171)\r\n    in MyLayout (created by Route)\r\n    in Route (created by CoreAdminRouter)\r\n    in Switch (created by CoreAdminRouter)\r\n    in div (created by CoreAdminRouter)\r\n    in CoreAdminRouter (created by Connect(CoreAdminRouter))\r\n    in Connect(CoreAdminRouter) (created by getContext(Connect(CoreAdminRouter)))\r\n    in getContext(Connect(CoreAdminRouter)) (created by Route)\r\n    in Route (created by CoreAdmin)\r\n    in Switch (created by CoreAdmin)\r\n    in Router (created by ConnectedRouter)\r\n    in ConnectedRouter (created by CoreAdmin)\r\n    in TranslationProviderView (created by Connect(TranslationProviderView))\r\n    in Connect(TranslationProviderView) (created by CoreAdmin)\r\n    in Provider (created by CoreAdmin)\r\n    in CoreAdmin (created by withContext(CoreAdmin))\r\n    in withContext(CoreAdmin) (at App.js:214)\r\n    in App (at src/index.js:15)\r\n"}}
{"actor":{"display_login":"pichichi40"}}