{"action":"created","comment":{"url":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/comments/23326390","id":23326390,"diff_hunk":"@@ -502,7 +528,19 @@ protected function loadValueOptions()\n                 $value = current($metadata->getIdentifierValues($object));\n             }\n \n-            $options[] = array('label' => $label, 'value' => $value);\n+            foreach ($this->getOptionAttributes() as $optionAttribute) {\n+                $methodName=current($optionAttribute);\n+                if (!is_callable(array($object, $methodName))) {\n+\n+                        throw new RuntimeException(\n+                            sprintf('Method \"%s::%s\" is not callable', $this->targetClass, $methodName)\n+                        );\n+                }\n+                    $optionAttributes[key($optionAttribute)] =(string) $object->{$methodName}();\n+            }\n+\n+                $options[] = array('label' => $label, 'value' => $value, 'attributes'=>$optionAttributes);","path":"src/DoctrineModule/Form/Element/Proxy.php","position":70,"original_position":70,"commit_id":"0928d23de596f6ec9ab8f8f4f285276c6a46fbc5","original_commit_id":"0928d23de596f6ec9ab8f8f4f285276c6a46fbc5","user":{"login":"jaapio","id":1060433,"avatar_url":"https://avatars.githubusercontent.com/u/1060433?v=3","gravatar_id":"","url":"https://api.github.com/users/jaapio","html_url":"https://github.com/jaapio","followers_url":"https://api.github.com/users/jaapio/followers","following_url":"https://api.github.com/users/jaapio/following{/other_user}","gists_url":"https://api.github.com/users/jaapio/gists{/gist_id}","starred_url":"https://api.github.com/users/jaapio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaapio/subscriptions","organizations_url":"https://api.github.com/users/jaapio/orgs","repos_url":"https://api.github.com/users/jaapio/repos","events_url":"https://api.github.com/users/jaapio/events{/privacy}","received_events_url":"https://api.github.com/users/jaapio/received_events","type":"User","site_admin":false},"body":"needs less indenting","created_at":"2015-01-21T19:26:53Z","updated_at":"2015-01-21T19:26:53Z","html_url":"https://github.com/doctrine/DoctrineModule/pull/446#discussion_r23326390","pull_request_url":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/446","_links":{"self":{"href":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/comments/23326390"},"html":{"href":"https://github.com/doctrine/DoctrineModule/pull/446#discussion_r23326390"},"pull_request":{"href":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/446"}}},"pull_request":{"url":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/446","id":23718204,"html_url":"https://github.com/doctrine/DoctrineModule/pull/446","diff_url":"https://github.com/doctrine/DoctrineModule/pull/446.diff","patch_url":"https://github.com/doctrine/DoctrineModule/pull/446.patch","issue_url":"https://api.github.com/repos/doctrine/DoctrineModule/issues/446","number":446,"state":"open","locked":false,"title":"Added functionality to support custom valueOption attributes","user":{"login":"matwright","id":4989280,"avatar_url":"https://avatars.githubusercontent.com/u/4989280?v=3","gravatar_id":"","url":"https://api.github.com/users/matwright","html_url":"https://github.com/matwright","followers_url":"https://api.github.com/users/matwright/followers","following_url":"https://api.github.com/users/matwright/following{/other_user}","gists_url":"https://api.github.com/users/matwright/gists{/gist_id}","starred_url":"https://api.github.com/users/matwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matwright/subscriptions","organizations_url":"https://api.github.com/users/matwright/orgs","repos_url":"https://api.github.com/users/matwright/repos","events_url":"https://api.github.com/users/matwright/events{/privacy}","received_events_url":"https://api.github.com/users/matwright/received_events","type":"User","site_admin":false},"body":"A useful feature with ZF2 form elements that have valueOptions is being able to set custom attributes on each valueOption.\r\nIn the following example the custom attribute 'data-key' is set on each valueOption.\r\n```\r\n$select=new \\Zend\\Form\\Element\\Select('test');\r\n$select->setValueOptions(\r\n    [\r\n        ['attributes'=>['data-key'=>'value'],'value'=>'myValue','label'=>'myLabel'],\r\n        ['attributes'=>['data-key'=>'value2'],'value'=>'myValue2','label'=>'myLabel2']\r\n    ]\r\n\r\n    );\r\n\r\necho $this->formselect($select);\r\n```\r\nthe element view helper returns the following HTML:\r\n```\r\n<select name=\"test\">\r\n<option value=\"myValue\" data-key=\"value\">myLabel</option>\r\n<option value=\"myValue2\" data-key=\"value2\">myLabel2</option>\r\n</select>\r\n```\r\nBeing able to add these attributes to valueoptions is extremely useful for passing additional values for front-end processing, like adding a boolean value for an objects status, category or timestamp, etc.\r\n\r\nDoctrineModule currently only supports label and value attributes for its ObjectSelect feature. This PR includes functionality to define custom attributes using a option_attributes option.\r\n\r\nThe attributes would be defined using a new  'option_attributes' key :\r\n```\r\n$os->setOptions([\r\n            'object_manager' => $odm,\r\n            'target_class' => '\\Entity\\SomeEntity',\r\n            'property' => 'name',\r\n            'option_attributes' => [\r\n            [ 'data-type'=>'getType']\r\n            ],\r\n            'find_method' => [\r\n                'name' => 'findAll',\r\n                'params' => []\r\n           ]\r\n        ]);\r\n```\r\nWhereby the key option_attributes accepts an array of key/values, the keys represent valid HTML attributes(these are already filtered in ZF2 Select) they typically include  attributes such as data-, aria-, onEvent, etc. The value (getType in the above code example) is a method which will be called on the object and used for the option attribute value.\r\n\r\n```\r\ndata-key=\"value\"\r\n```","created_at":"2014-11-01T10:54:33Z","updated_at":"2015-01-21T19:26:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef20369b6399faf7bcd3ed2b5aed0b93aa44c1bf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/446/commits","review_comments_url":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/446/comments","review_comment_url":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/comments/{number}","comments_url":"https://api.github.com/repos/doctrine/DoctrineModule/issues/446/comments","statuses_url":"https://api.github.com/repos/doctrine/DoctrineModule/statuses/0928d23de596f6ec9ab8f8f4f285276c6a46fbc5","head":{"label":"matwright:master","ref":"master","sha":"0928d23de596f6ec9ab8f8f4f285276c6a46fbc5","user":{"login":"matwright","id":4989280,"avatar_url":"https://avatars.githubusercontent.com/u/4989280?v=3","gravatar_id":"","url":"https://api.github.com/users/matwright","html_url":"https://github.com/matwright","followers_url":"https://api.github.com/users/matwright/followers","following_url":"https://api.github.com/users/matwright/following{/other_user}","gists_url":"https://api.github.com/users/matwright/gists{/gist_id}","starred_url":"https://api.github.com/users/matwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matwright/subscriptions","organizations_url":"https://api.github.com/users/matwright/orgs","repos_url":"https://api.github.com/users/matwright/repos","events_url":"https://api.github.com/users/matwright/events{/privacy}","received_events_url":"https://api.github.com/users/matwright/received_events","type":"User","site_admin":false},"repo":{"id":19881900,"name":"DoctrineModule","full_name":"matwright/DoctrineModule","owner":{"login":"matwright","id":4989280,"avatar_url":"https://avatars.githubusercontent.com/u/4989280?v=3","gravatar_id":"","url":"https://api.github.com/users/matwright","html_url":"https://github.com/matwright","followers_url":"https://api.github.com/users/matwright/followers","following_url":"https://api.github.com/users/matwright/following{/other_user}","gists_url":"https://api.github.com/users/matwright/gists{/gist_id}","starred_url":"https://api.github.com/users/matwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matwright/subscriptions","organizations_url":"https://api.github.com/users/matwright/orgs","repos_url":"https://api.github.com/users/matwright/repos","events_url":"https://api.github.com/users/matwright/events{/privacy}","received_events_url":"https://api.github.com/users/matwright/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matwright/DoctrineModule","description":"Zend Framework 2 Module for Doctrine","fork":true,"url":"https://api.github.com/repos/matwright/DoctrineModule","forks_url":"https://api.github.com/repos/matwright/DoctrineModule/forks","keys_url":"https://api.github.com/repos/matwright/DoctrineModule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matwright/DoctrineModule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matwright/DoctrineModule/teams","hooks_url":"https://api.github.com/repos/matwright/DoctrineModule/hooks","issue_events_url":"https://api.github.com/repos/matwright/DoctrineModule/issues/events{/number}","events_url":"https://api.github.com/repos/matwright/DoctrineModule/events","assignees_url":"https://api.github.com/repos/matwright/DoctrineModule/assignees{/user}","branches_url":"https://api.github.com/repos/matwright/DoctrineModule/branches{/branch}","tags_url":"https://api.github.com/repos/matwright/DoctrineModule/tags","blobs_url":"https://api.github.com/repos/matwright/DoctrineModule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matwright/DoctrineModule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matwright/DoctrineModule/git/refs{/sha}","trees_url":"https://api.github.com/repos/matwright/DoctrineModule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matwright/DoctrineModule/statuses/{sha}","languages_url":"https://api.github.com/repos/matwright/DoctrineModule/languages","stargazers_url":"https://api.github.com/repos/matwright/DoctrineModule/stargazers","contributors_url":"https://api.github.com/repos/matwright/DoctrineModule/contributors","subscribers_url":"https://api.github.com/repos/matwright/DoctrineModule/subscribers","subscription_url":"https://api.github.com/repos/matwright/DoctrineModule/subscription","commits_url":"https://api.github.com/repos/matwright/DoctrineModule/commits{/sha}","git_commits_url":"https://api.github.com/repos/matwright/DoctrineModule/git/commits{/sha}","comments_url":"https://api.github.com/repos/matwright/DoctrineModule/comments{/number}","issue_comment_url":"https://api.github.com/repos/matwright/DoctrineModule/issues/comments/{number}","contents_url":"https://api.github.com/repos/matwright/DoctrineModule/contents/{+path}","compare_url":"https://api.github.com/repos/matwright/DoctrineModule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matwright/DoctrineModule/merges","archive_url":"https://api.github.com/repos/matwright/DoctrineModule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matwright/DoctrineModule/downloads","issues_url":"https://api.github.com/repos/matwright/DoctrineModule/issues{/number}","pulls_url":"https://api.github.com/repos/matwright/DoctrineModule/pulls{/number}","milestones_url":"https://api.github.com/repos/matwright/DoctrineModule/milestones{/number}","notifications_url":"https://api.github.com/repos/matwright/DoctrineModule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matwright/DoctrineModule/labels{/name}","releases_url":"https://api.github.com/repos/matwright/DoctrineModule/releases{/id}","created_at":"2014-05-17T08:08:29Z","updated_at":"2014-10-31T15:40:14Z","pushed_at":"2014-12-17T13:26:15Z","git_url":"git://github.com/matwright/DoctrineModule.git","ssh_url":"git@github.com:matwright/DoctrineModule.git","clone_url":"https://github.com/matwright/DoctrineModule.git","svn_url":"https://github.com/matwright/DoctrineModule","homepage":"http://www.doctrine-project.org/jira","size":2019,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"doctrine:master","ref":"master","sha":"c5a206cdb67fe93fed94ca7e5fa0ba9cc9ff1f69","user":{"login":"doctrine","id":209254,"avatar_url":"https://avatars.githubusercontent.com/u/209254?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrine","html_url":"https://github.com/doctrine","followers_url":"https://api.github.com/users/doctrine/followers","following_url":"https://api.github.com/users/doctrine/following{/other_user}","gists_url":"https://api.github.com/users/doctrine/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrine/subscriptions","organizations_url":"https://api.github.com/users/doctrine/orgs","repos_url":"https://api.github.com/users/doctrine/repos","events_url":"https://api.github.com/users/doctrine/events{/privacy}","received_events_url":"https://api.github.com/users/doctrine/received_events","type":"Organization","site_admin":false},"repo":{"id":3072250,"name":"DoctrineModule","full_name":"doctrine/DoctrineModule","owner":{"login":"doctrine","id":209254,"avatar_url":"https://avatars.githubusercontent.com/u/209254?v=3","gravatar_id":"","url":"https://api.github.com/users/doctrine","html_url":"https://github.com/doctrine","followers_url":"https://api.github.com/users/doctrine/followers","following_url":"https://api.github.com/users/doctrine/following{/other_user}","gists_url":"https://api.github.com/users/doctrine/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrine/subscriptions","organizations_url":"https://api.github.com/users/doctrine/orgs","repos_url":"https://api.github.com/users/doctrine/repos","events_url":"https://api.github.com/users/doctrine/events{/privacy}","received_events_url":"https://api.github.com/users/doctrine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/doctrine/DoctrineModule","description":"Zend Framework 2 Module for Doctrine","fork":false,"url":"https://api.github.com/repos/doctrine/DoctrineModule","forks_url":"https://api.github.com/repos/doctrine/DoctrineModule/forks","keys_url":"https://api.github.com/repos/doctrine/DoctrineModule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/doctrine/DoctrineModule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/doctrine/DoctrineModule/teams","hooks_url":"https://api.github.com/repos/doctrine/DoctrineModule/hooks","issue_events_url":"https://api.github.com/repos/doctrine/DoctrineModule/issues/events{/number}","events_url":"https://api.github.com/repos/doctrine/DoctrineModule/events","assignees_url":"https://api.github.com/repos/doctrine/DoctrineModule/assignees{/user}","branches_url":"https://api.github.com/repos/doctrine/DoctrineModule/branches{/branch}","tags_url":"https://api.github.com/repos/doctrine/DoctrineModule/tags","blobs_url":"https://api.github.com/repos/doctrine/DoctrineModule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/doctrine/DoctrineModule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/doctrine/DoctrineModule/git/refs{/sha}","trees_url":"https://api.github.com/repos/doctrine/DoctrineModule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/doctrine/DoctrineModule/statuses/{sha}","languages_url":"https://api.github.com/repos/doctrine/DoctrineModule/languages","stargazers_url":"https://api.github.com/repos/doctrine/DoctrineModule/stargazers","contributors_url":"https://api.github.com/repos/doctrine/DoctrineModule/contributors","subscribers_url":"https://api.github.com/repos/doctrine/DoctrineModule/subscribers","subscription_url":"https://api.github.com/repos/doctrine/DoctrineModule/subscription","commits_url":"https://api.github.com/repos/doctrine/DoctrineModule/commits{/sha}","git_commits_url":"https://api.github.com/repos/doctrine/DoctrineModule/git/commits{/sha}","comments_url":"https://api.github.com/repos/doctrine/DoctrineModule/comments{/number}","issue_comment_url":"https://api.github.com/repos/doctrine/DoctrineModule/issues/comments/{number}","contents_url":"https://api.github.com/repos/doctrine/DoctrineModule/contents/{+path}","compare_url":"https://api.github.com/repos/doctrine/DoctrineModule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/doctrine/DoctrineModule/merges","archive_url":"https://api.github.com/repos/doctrine/DoctrineModule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/doctrine/DoctrineModule/downloads","issues_url":"https://api.github.com/repos/doctrine/DoctrineModule/issues{/number}","pulls_url":"https://api.github.com/repos/doctrine/DoctrineModule/pulls{/number}","milestones_url":"https://api.github.com/repos/doctrine/DoctrineModule/milestones{/number}","notifications_url":"https://api.github.com/repos/doctrine/DoctrineModule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/doctrine/DoctrineModule/labels{/name}","releases_url":"https://api.github.com/repos/doctrine/DoctrineModule/releases{/id}","created_at":"2011-12-30T01:44:19Z","updated_at":"2015-01-19T18:49:34Z","pushed_at":"2015-01-08T20:44:26Z","git_url":"git://github.com/doctrine/DoctrineModule.git","ssh_url":"git@github.com:doctrine/DoctrineModule.git","clone_url":"https://github.com/doctrine/DoctrineModule.git","svn_url":"https://github.com/doctrine/DoctrineModule","homepage":"http://www.doctrine-project.org/jira","size":3794,"stargazers_count":291,"watchers_count":291,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":206,"mirror_url":null,"open_issues_count":80,"forks":206,"open_issues":80,"watchers":291,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/446"},"html":{"href":"https://github.com/doctrine/DoctrineModule/pull/446"},"issue":{"href":"https://api.github.com/repos/doctrine/DoctrineModule/issues/446"},"comments":{"href":"https://api.github.com/repos/doctrine/DoctrineModule/issues/446/comments"},"review_comments":{"href":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/446/comments"},"review_comment":{"href":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/doctrine/DoctrineModule/pulls/446/commits"},"statuses":{"href":"https://api.github.com/repos/doctrine/DoctrineModule/statuses/0928d23de596f6ec9ab8f8f4f285276c6a46fbc5"}}}}