{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony-demo/pulls/comments/43134502","id":43134502,"diff_hunk":"@@ -0,0 +1,75 @@\n+<?php\n+\n+/*\n+ * This file is part of the Symfony package.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace AppBundle\\Form\\Type;\n+\n+use AppBundle\\Utils\\MomentFormatConverter;\n+use Symfony\\Component\\Form\\AbstractType;\n+use Symfony\\Component\\Form\\FormInterface;\n+use Symfony\\Component\\Form\\FormView;\n+use Symfony\\Component\\OptionsResolver\\OptionsResolver;\n+\n+/**\n+ * Defines the custom form field type used to manipulate datetime values across\n+ * Bootstrap Date\\Time Picker javascript plugin.\n+ * See http://symfony.com/doc/current/cookbook/create_custom_field_type.html\n+ *\n+ * @author Yonel Ceruto <yonelceruto@gmail.com>\n+ */\n+class DateTimePickerType extends AbstractType\n+{\n+    /**\n+     * @var MomentFormatConverter\n+     */\n+    private $formatConverter;\n+\n+    public function __construct()\n+    {\n+        $this->formatConverter = new MomentFormatConverter();\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function buildView(FormView $view, FormInterface $form, array $options)\n+    {\n+        $view->vars['attr'] = array_merge($view->vars['attr'], array(","path":"src/AppBundle/Form/Type/DateTimePickerType.php","position":44,"original_position":44,"commit_id":"07a1a38e1ece58b9c01181a7a6f7396eebc73284","original_commit_id":"07a1a38e1ece58b9c01181a7a6f7396eebc73284","user":{"login":"voronkovich","id":2299535,"avatar_url":"https://avatars.githubusercontent.com/u/2299535?v=3","gravatar_id":"","url":"https://api.github.com/users/voronkovich","html_url":"https://github.com/voronkovich","followers_url":"https://api.github.com/users/voronkovich/followers","following_url":"https://api.github.com/users/voronkovich/following{/other_user}","gists_url":"https://api.github.com/users/voronkovich/gists{/gist_id}","starred_url":"https://api.github.com/users/voronkovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voronkovich/subscriptions","organizations_url":"https://api.github.com/users/voronkovich/orgs","repos_url":"https://api.github.com/users/voronkovich/repos","events_url":"https://api.github.com/users/voronkovich/events{/privacy}","received_events_url":"https://api.github.com/users/voronkovich/received_events","type":"User","site_admin":false},"body":"@yceruto ok, my bad. But you can do it without using `array_merge`:\r\n\r\n```php\r\npublic function buildView(FormView $view, FormInterface $form, array $options)\r\n{\r\n    $view->vars['attr']['data-date-format'] = $this->formatConverter->convert($options['format']);\r\n    $view->vars['attr']['data-date-locale'] = \\Locale::getDefault():\r\n}\r\n```","created_at":"2015-10-27T15:08:48Z","updated_at":"2015-10-27T15:08:48Z","html_url":"https://github.com/symfony/symfony-demo/pull/239#discussion_r43134502","pull_request_url":"https://api.github.com/repos/symfony/symfony-demo/pulls/239","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony-demo/pulls/comments/43134502"},"html":{"href":"https://github.com/symfony/symfony-demo/pull/239#discussion_r43134502"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony-demo/pulls/239"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony-demo/pulls/239","id":48706904,"html_url":"https://github.com/symfony/symfony-demo/pull/239","diff_url":"https://github.com/symfony/symfony-demo/pull/239.diff","patch_url":"https://github.com/symfony/symfony-demo/pull/239.patch","issue_url":"https://api.github.com/repos/symfony/symfony-demo/issues/239","number":239,"state":"open","locked":false,"title":"add a custom form field type example","user":{"login":"yceruto","id":2028198,"avatar_url":"https://avatars.githubusercontent.com/u/2028198?v=3","gravatar_id":"","url":"https://api.github.com/users/yceruto","html_url":"https://github.com/yceruto","followers_url":"https://api.github.com/users/yceruto/followers","following_url":"https://api.github.com/users/yceruto/following{/other_user}","gists_url":"https://api.github.com/users/yceruto/gists{/gist_id}","starred_url":"https://api.github.com/users/yceruto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yceruto/subscriptions","organizations_url":"https://api.github.com/users/yceruto/orgs","repos_url":"https://api.github.com/users/yceruto/repos","events_url":"https://api.github.com/users/yceruto/events{/privacy}","received_events_url":"https://api.github.com/users/yceruto/received_events","type":"User","site_admin":false},"body":"**The first purpose** of this PR is to provide a practical example of how to create a custom form field type.\r\n\r\n**The second purpose** is to improve the user interface to the field \"Published At\" on edit a Post, \r\nusing a JavaScript date library like bootstrap-datetimepicker for parsing, validating, manipulating, and formatting dates. http://eonasdan.github.io/bootstrap-datetimepicker.\r\n\r\n>**Important:** Is not the purpose of this PR create a custom form field type to support all options and features of the datetimepicker plugin.\r\n\r\nReferences:\r\n* http://symfony.com/doc/current/cookbook/create_custom_field_type.html\r\n* http://symfony.com/doc/current/best_practices/forms.html#custom-form-field-types\r\n\r\nMain Topics:\r\n* Defining the custom form Field Type.\r\n* Creating your form Field Type as a Service.\r\n* Creating a Template for the custom form field Type\r\n* Configuring the custom form template.\r\n* Initializing datetime picker JavaScript plugin.\r\n* Using the form Field Type into PostType form.\r\n\r\nOthers Topics (refactor):\r\n* Moving the initialization of the highligth JavaScript plugin for `main.js` file.\r\n\r\n**Preview:**\r\n![datetimepicker](https://cloud.githubusercontent.com/assets/2028198/10723013/d1930664-7b8c-11e5-9409-ec8b369a1c2f.png)","created_at":"2015-10-26T06:58:51Z","updated_at":"2015-10-27T15:08:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"74f57ee962597bd11f15792a6f19638b845e1698","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony-demo/pulls/239/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony-demo/pulls/239/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony-demo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony-demo/issues/239/comments","statuses_url":"https://api.github.com/repos/symfony/symfony-demo/statuses/07a1a38e1ece58b9c01181a7a6f7396eebc73284","head":{"label":"yceruto:custom-form-field-type-example","ref":"custom-form-field-type-example","sha":"07a1a38e1ece58b9c01181a7a6f7396eebc73284","user":{"login":"yceruto","id":2028198,"avatar_url":"https://avatars.githubusercontent.com/u/2028198?v=3","gravatar_id":"","url":"https://api.github.com/users/yceruto","html_url":"https://github.com/yceruto","followers_url":"https://api.github.com/users/yceruto/followers","following_url":"https://api.github.com/users/yceruto/following{/other_user}","gists_url":"https://api.github.com/users/yceruto/gists{/gist_id}","starred_url":"https://api.github.com/users/yceruto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yceruto/subscriptions","organizations_url":"https://api.github.com/users/yceruto/orgs","repos_url":"https://api.github.com/users/yceruto/repos","events_url":"https://api.github.com/users/yceruto/events{/privacy}","received_events_url":"https://api.github.com/users/yceruto/received_events","type":"User","site_admin":false},"repo":{"id":42252970,"name":"symfony-demo","full_name":"yceruto/symfony-demo","owner":{"login":"yceruto","id":2028198,"avatar_url":"https://avatars.githubusercontent.com/u/2028198?v=3","gravatar_id":"","url":"https://api.github.com/users/yceruto","html_url":"https://github.com/yceruto","followers_url":"https://api.github.com/users/yceruto/followers","following_url":"https://api.github.com/users/yceruto/following{/other_user}","gists_url":"https://api.github.com/users/yceruto/gists{/gist_id}","starred_url":"https://api.github.com/users/yceruto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yceruto/subscriptions","organizations_url":"https://api.github.com/users/yceruto/orgs","repos_url":"https://api.github.com/users/yceruto/repos","events_url":"https://api.github.com/users/yceruto/events{/privacy}","received_events_url":"https://api.github.com/users/yceruto/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yceruto/symfony-demo","description":"","fork":true,"url":"https://api.github.com/repos/yceruto/symfony-demo","forks_url":"https://api.github.com/repos/yceruto/symfony-demo/forks","keys_url":"https://api.github.com/repos/yceruto/symfony-demo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yceruto/symfony-demo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yceruto/symfony-demo/teams","hooks_url":"https://api.github.com/repos/yceruto/symfony-demo/hooks","issue_events_url":"https://api.github.com/repos/yceruto/symfony-demo/issues/events{/number}","events_url":"https://api.github.com/repos/yceruto/symfony-demo/events","assignees_url":"https://api.github.com/repos/yceruto/symfony-demo/assignees{/user}","branches_url":"https://api.github.com/repos/yceruto/symfony-demo/branches{/branch}","tags_url":"https://api.github.com/repos/yceruto/symfony-demo/tags","blobs_url":"https://api.github.com/repos/yceruto/symfony-demo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yceruto/symfony-demo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yceruto/symfony-demo/git/refs{/sha}","trees_url":"https://api.github.com/repos/yceruto/symfony-demo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yceruto/symfony-demo/statuses/{sha}","languages_url":"https://api.github.com/repos/yceruto/symfony-demo/languages","stargazers_url":"https://api.github.com/repos/yceruto/symfony-demo/stargazers","contributors_url":"https://api.github.com/repos/yceruto/symfony-demo/contributors","subscribers_url":"https://api.github.com/repos/yceruto/symfony-demo/subscribers","subscription_url":"https://api.github.com/repos/yceruto/symfony-demo/subscription","commits_url":"https://api.github.com/repos/yceruto/symfony-demo/commits{/sha}","git_commits_url":"https://api.github.com/repos/yceruto/symfony-demo/git/commits{/sha}","comments_url":"https://api.github.com/repos/yceruto/symfony-demo/comments{/number}","issue_comment_url":"https://api.github.com/repos/yceruto/symfony-demo/issues/comments{/number}","contents_url":"https://api.github.com/repos/yceruto/symfony-demo/contents/{+path}","compare_url":"https://api.github.com/repos/yceruto/symfony-demo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yceruto/symfony-demo/merges","archive_url":"https://api.github.com/repos/yceruto/symfony-demo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yceruto/symfony-demo/downloads","issues_url":"https://api.github.com/repos/yceruto/symfony-demo/issues{/number}","pulls_url":"https://api.github.com/repos/yceruto/symfony-demo/pulls{/number}","milestones_url":"https://api.github.com/repos/yceruto/symfony-demo/milestones{/number}","notifications_url":"https://api.github.com/repos/yceruto/symfony-demo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yceruto/symfony-demo/labels{/name}","releases_url":"https://api.github.com/repos/yceruto/symfony-demo/releases{/id}","created_at":"2015-09-10T15:25:08Z","updated_at":"2015-09-10T15:25:08Z","pushed_at":"2015-10-26T20:15:33Z","git_url":"git://github.com/yceruto/symfony-demo.git","ssh_url":"git@github.com:yceruto/symfony-demo.git","clone_url":"https://github.com/yceruto/symfony-demo.git","svn_url":"https://github.com/yceruto/symfony-demo","homepage":null,"size":1539,"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":"symfony:master","ref":"master","sha":"6e4e20b71c58eb6321fbf50353343b40727e0441","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":32792088,"name":"symfony-demo","full_name":"symfony/symfony-demo","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony-demo","description":"","fork":false,"url":"https://api.github.com/repos/symfony/symfony-demo","forks_url":"https://api.github.com/repos/symfony/symfony-demo/forks","keys_url":"https://api.github.com/repos/symfony/symfony-demo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony-demo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony-demo/teams","hooks_url":"https://api.github.com/repos/symfony/symfony-demo/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony-demo/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony-demo/events","assignees_url":"https://api.github.com/repos/symfony/symfony-demo/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony-demo/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony-demo/tags","blobs_url":"https://api.github.com/repos/symfony/symfony-demo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony-demo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony-demo/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony-demo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony-demo/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony-demo/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony-demo/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony-demo/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony-demo/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony-demo/subscription","commits_url":"https://api.github.com/repos/symfony/symfony-demo/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony-demo/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony-demo/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony-demo/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony-demo/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony-demo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony-demo/merges","archive_url":"https://api.github.com/repos/symfony/symfony-demo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony-demo/downloads","issues_url":"https://api.github.com/repos/symfony/symfony-demo/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony-demo/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony-demo/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony-demo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony-demo/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony-demo/releases{/id}","created_at":"2015-03-24T10:37:08Z","updated_at":"2015-10-26T11:56:09Z","pushed_at":"2015-10-26T20:15:33Z","git_url":"git://github.com/symfony/symfony-demo.git","ssh_url":"git@github.com:symfony/symfony-demo.git","clone_url":"https://github.com/symfony/symfony-demo.git","svn_url":"https://github.com/symfony/symfony-demo","homepage":null,"size":4436,"stargazers_count":248,"watchers_count":248,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":116,"mirror_url":null,"open_issues_count":13,"forks":116,"open_issues":13,"watchers":248,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony-demo/pulls/239"},"html":{"href":"https://github.com/symfony/symfony-demo/pull/239"},"issue":{"href":"https://api.github.com/repos/symfony/symfony-demo/issues/239"},"comments":{"href":"https://api.github.com/repos/symfony/symfony-demo/issues/239/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony-demo/pulls/239/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony-demo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony-demo/pulls/239/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony-demo/statuses/07a1a38e1ece58b9c01181a7a6f7396eebc73284"}}}}