{"action":"created","issue":{"url":"https://api.github.com/repos/octobercms/october/issues/2451","repository_url":"https://api.github.com/repos/octobercms/october","labels_url":"https://api.github.com/repos/octobercms/october/issues/2451/labels{/name}","comments_url":"https://api.github.com/repos/octobercms/october/issues/2451/comments","events_url":"https://api.github.com/repos/octobercms/october/issues/2451/events","html_url":"https://github.com/octobercms/october/issues/2451","id":186085533,"number":2451,"title":"Repeater with hasMany relation - Backend","user":{"login":"leoquijano","id":7789514,"avatar_url":"https://avatars.githubusercontent.com/u/7789514?v=3","gravatar_id":"","url":"https://api.github.com/users/leoquijano","html_url":"https://github.com/leoquijano","followers_url":"https://api.github.com/users/leoquijano/followers","following_url":"https://api.github.com/users/leoquijano/following{/other_user}","gists_url":"https://api.github.com/users/leoquijano/gists{/gist_id}","starred_url":"https://api.github.com/users/leoquijano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leoquijano/subscriptions","organizations_url":"https://api.github.com/users/leoquijano/orgs","repos_url":"https://api.github.com/users/leoquijano/repos","events_url":"https://api.github.com/users/leoquijano/events{/privacy}","received_events_url":"https://api.github.com/users/leoquijano/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-29T15:52:15Z","updated_at":"2016-11-04T13:45:53Z","closed_at":null,"body":"Hi,\n\nI'm building a backend form with a repeater component. This is the $hasMany entry in the parent model (Plan):\n\nPlugin\\Models\\Plan class:\n\n``` php\npublic $hasMany       = [\n  'trustees' => 'Plugin\\Models\\PlanTrustee',\n];\n```\n\nAnd this is my YAML field configuration:\n\n```\n    ...\n    trustees:\n        label: Trustees\n        type: repeater\n        span: left\n        prompt: Add New Trustee\n        form:\n            fields:\n                first_name:\n                    label: First Name\n                    type: text\n                last_name:\n                    label: Last Name\n                    type: text\n```\n\nHowever, when I try to open an existing plan, I get N repeater items (as many as there are trustees), but they're all empty. And when a try to create a new plan (in this case with a Foo Bar trustee), I get this error:\n\n```\nSQLSTATE[HY093]: Invalid parameter number: parameter was not defined (SQL: select * from \"plan_trustees\" where \"id\" in (Foo, Bar))\" on line 662 of /vendor/laravel/framework/src/Illuminate/Database/Connection.php\n```\n\nThe database tables are the usual:\n\n``` php\nSchema::create('plans', function (Blueprint $table) {\n  $table->increments('id');\n  // ...\n});\n\nSchema::create('plan_trustees', function (Blueprint $table) {\n  $table->increments('id');\n  $table->unsignedInteger('plan_id');\n  $table->string(\"first_name\", 50);\n  $table->string(\"last_name\", 50);\n  $table->timestamps();\n  $table->foreign(\"plan_id\")->references(\"id\")->on(\"plans\")->onDelete(\"cascade\");\n});\n```\n\nI'm using the following versions of October CMS:\n- october/rain (dev-master 7325e01)\n- october/system (dev-master badbc24)\n- october/backend (dev-master 9efa3de)\n- october/cms (dev-master 9cd9a2e)\n\nIs this feature working with relations?\n"},"comment":{"url":"https://api.github.com/repos/octobercms/october/issues/comments/258434810","html_url":"https://github.com/octobercms/october/issues/2451#issuecomment-258434810","issue_url":"https://api.github.com/repos/octobercms/october/issues/2451","id":258434810,"user":{"login":"Patroklo","id":1254017,"avatar_url":"https://avatars.githubusercontent.com/u/1254017?v=3","gravatar_id":"","url":"https://api.github.com/users/Patroklo","html_url":"https://github.com/Patroklo","followers_url":"https://api.github.com/users/Patroklo/followers","following_url":"https://api.github.com/users/Patroklo/following{/other_user}","gists_url":"https://api.github.com/users/Patroklo/gists{/gist_id}","starred_url":"https://api.github.com/users/Patroklo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Patroklo/subscriptions","organizations_url":"https://api.github.com/users/Patroklo/orgs","repos_url":"https://api.github.com/users/Patroklo/repos","events_url":"https://api.github.com/users/Patroklo/events{/privacy}","received_events_url":"https://api.github.com/users/Patroklo/received_events","type":"User","site_admin":false},"created_at":"2016-11-04T13:45:53Z","updated_at":"2016-11-04T13:45:53Z","body":"[It works!!!!](http://hellonwheels.com.au/bmxshop/wp-content/uploads/2015/05/alive.jpg) Really it doesn't have much sense, but you can use a SINGLE field from another model in a repeater. It will store all data as JSON (still thinking what you need in this case is a relation, though).\r\n\r\n[Moar data here, only change the text field for a repeater and will work just fine](https://octobercms.com/forum/post/howto-create-two-models-on-a-single-form-a-guide-to-proxy-fields)"}}
{"actor":{"display_login":"Patroklo"}}