{"action":"created","issue":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/11579","repository_url":"https://api.github.com/repos/phalcon/cphalcon","labels_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11579/labels{/name}","comments_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11579/comments","events_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11579/events","html_url":"https://github.com/phalcon/cphalcon/issues/11579","id":142644350,"number":11579,"title":"Запрос на добавление возможности добавлять под-формы в Phalcon\\Forms\\Form и добавлять коллекции элементов","user":{"login":"dilistinc","id":6850508,"avatar_url":"https://avatars.githubusercontent.com/u/6850508?v=3","gravatar_id":"","url":"https://api.github.com/users/dilistinc","html_url":"https://github.com/dilistinc","followers_url":"https://api.github.com/users/dilistinc/followers","following_url":"https://api.github.com/users/dilistinc/following{/other_user}","gists_url":"https://api.github.com/users/dilistinc/gists{/gist_id}","starred_url":"https://api.github.com/users/dilistinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilistinc/subscriptions","organizations_url":"https://api.github.com/users/dilistinc/orgs","repos_url":"https://api.github.com/users/dilistinc/repos","events_url":"https://api.github.com/users/dilistinc/events{/privacy}","received_events_url":"https://api.github.com/users/dilistinc/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/phalcon/cphalcon/labels/New%20Feature%20Request","name":"New Feature Request","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-22T13:06:35Z","updated_at":"2016-03-22T13:13:38Z","closed_at":null,"body":"_Просьба перевести на english_\r\n\r\n> Работа с HTML-форм является одним из наиболее распространенных - и сложных - задач для веб-разработчиков.\r\n\r\nPhalcon\\Forms\\Form очень простой и лаконичный компонент, но к сожалению его функционала не хватает для решения основных повседневных задач. В связи с этим предлагаю:\r\n### Добавить возможность в **Phalcon\\Forms\\Form** добавлять под-формы(объекты Phalcon\\Forms\\Form) в качестве элементов и добавить новый элемент типу Collection который может содержать несколько элементов включая под-форму.\r\n\r\nЭта возможность так-же должна включать:\r\n1. Метод **Phalcon\\Forms\\Form->bind()** должен биндить данные в подформы и коллекции.\r\n2. Метод **Phalcon\\Forms\\Form->render()** должен рассчитывать имя элемента включая иерархию.\r\n\r\n\r\n### Пример использования:\r\nСоздание формы **Robot** которая содержит коллекцию подформ **RobotPart**\r\n\r\n```php\r\n<?php\r\n\r\nuse Phalcon\\Mvc\\Model;\r\nuse Phalcon\\Forms\\Form;\r\nuse Phalcon\\Forms\\Element;\r\n\r\nclass Robot extends Model\r\n{\r\n    protected $id;\r\n    protected $name;\r\n\r\n    protected function initialize()\r\n    {\r\n        $this->hasOne(\r\n            'id',\r\n            'RobotPart',\r\n            'robot_id'\r\n        );\r\n    }\r\n}\r\n\r\n\r\nclass RobotPart extends Model\r\n{\r\n    protected $id;\r\n    protected $robot_id;\r\n    protected $name;\r\n\r\n    protected function initialize()\r\n    {\r\n        $this->belongsTo(\r\n            'robot_id',\r\n            'Robot',\r\n            'id'\r\n        );\r\n    }\r\n}\r\n\r\n$robot = new Robot();\r\n\r\n$robotPartForm = new Form();\r\n$robotPartForm->add(new Element\\Text('name'));\r\n\r\n$robotForm = new Form($robot);\r\n$robotForm->add(new Element\\Text('name'));\r\n$robotForm->add(new Element\\Collection('robotPart', $robotPartForm));\r\n\r\n$robotForm->bind($robot, $_POST);\r\n\r\necho $robotForm->render('name');\r\n\r\n// Выводит несколько формы сущностями которых есть результат $robot->getRobotPart(), а если нету сущностей, выводит пустой единственный прототип\r\nforeach ($robotForm->get('robotPart') as $robotPartForm) {\r\n    // Должен вывести <input type=\"text\" name=\"robotPart[*индекс*][name]\" value=\"*value*/\">\r\n    echo $robotPartForm->render('name');\r\n}"},"comment":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/comments/199807076","html_url":"https://github.com/phalcon/cphalcon/issues/11579#issuecomment-199807076","issue_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11579","id":199807076,"user":{"login":"sergeyklay","id":1256298,"avatar_url":"https://avatars.githubusercontent.com/u/1256298?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeyklay","html_url":"https://github.com/sergeyklay","followers_url":"https://api.github.com/users/sergeyklay/followers","following_url":"https://api.github.com/users/sergeyklay/following{/other_user}","gists_url":"https://api.github.com/users/sergeyklay/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeyklay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeyklay/subscriptions","organizations_url":"https://api.github.com/users/sergeyklay/orgs","repos_url":"https://api.github.com/users/sergeyklay/repos","events_url":"https://api.github.com/users/sergeyklay/events{/privacy}","received_events_url":"https://api.github.com/users/sergeyklay/received_events","type":"User","site_admin":false},"created_at":"2016-03-22T13:13:38Z","updated_at":"2016-03-22T13:13:38Z","body":"Yes, in the evening guys. I'm little busy"}}