{"action":"created","issue":{"url":"https://api.github.com/repos/LaravelCollective/html/issues/89","labels_url":"https://api.github.com/repos/LaravelCollective/html/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/LaravelCollective/html/issues/89/comments","events_url":"https://api.github.com/repos/LaravelCollective/html/issues/89/events","html_url":"https://github.com/LaravelCollective/html/issues/89","id":108016573,"number":89,"title":"Select to check selected values from a collection","user":{"login":"rumeau","id":2340790,"avatar_url":"https://avatars.githubusercontent.com/u/2340790?v=3","gravatar_id":"","url":"https://api.github.com/users/rumeau","html_url":"https://github.com/rumeau","followers_url":"https://api.github.com/users/rumeau/followers","following_url":"https://api.github.com/users/rumeau/following{/other_user}","gists_url":"https://api.github.com/users/rumeau/gists{/gist_id}","starred_url":"https://api.github.com/users/rumeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rumeau/subscriptions","organizations_url":"https://api.github.com/users/rumeau/orgs","repos_url":"https://api.github.com/users/rumeau/repos","events_url":"https://api.github.com/users/rumeau/events{/privacy}","received_events_url":"https://api.github.com/users/rumeau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-23T22:02:04Z","updated_at":"2015-09-30T05:23:40Z","closed_at":null,"body":"Hello, i'm using FormBuilder to add a couple of select elements\r\n\r\nThis select fields are tied to a model relation.\r\n\r\nCurrently i workaround this with a custom attribute to retrieve the selected elements from the relation and converting them to an array so https://github.com/LaravelCollective/html/blob/5.1/src/FormBuilder.php#L660 can read this options.\r\n\r\nI'm thinking of adding a pull request for this to be taken care on the same method to allow for collections to be interpreted directly on the model.\r\n\r\nIE.\r\n\r\n```\r\n    if(is_array($selected))\r\n    {\r\n      return in_array($value, $selected) ? 'selected' : null;\r\n    }\r\n    elseif($selected instanceof Collection)\r\n    {\r\n      return $selected->contains('id', $value) ? 'selected' : null;\r\n    }\r\n```\r\n\r\nThe problem is that a many-to-many relation should be indexed by the 'id' field following laravel convention, but might be a case where the id actually calls ie. \"company_id\", in this case the 'id' field would be hardcoded on the condition.\r\n\r\nMy final issue is should i add this pull request or this should be handled by developers on their own models or views? Is this an issue to someone else or does this have enough support?\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/LaravelCollective/html/issues/comments/144285147","html_url":"https://github.com/LaravelCollective/html/issues/89#issuecomment-144285147","issue_url":"https://api.github.com/repos/LaravelCollective/html/issues/89","id":144285147,"user":{"login":"fhferreira","id":140686,"avatar_url":"https://avatars.githubusercontent.com/u/140686?v=3","gravatar_id":"","url":"https://api.github.com/users/fhferreira","html_url":"https://github.com/fhferreira","followers_url":"https://api.github.com/users/fhferreira/followers","following_url":"https://api.github.com/users/fhferreira/following{/other_user}","gists_url":"https://api.github.com/users/fhferreira/gists{/gist_id}","starred_url":"https://api.github.com/users/fhferreira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhferreira/subscriptions","organizations_url":"https://api.github.com/users/fhferreira/orgs","repos_url":"https://api.github.com/users/fhferreira/repos","events_url":"https://api.github.com/users/fhferreira/events{/privacy}","received_events_url":"https://api.github.com/users/fhferreira/received_events","type":"User","site_admin":false},"created_at":"2015-09-30T05:23:40Z","updated_at":"2015-09-30T05:23:40Z","body":"+1"}}