{"action":"opened","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/11546","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/11546/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/11546/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/11546/events","html_url":"https://github.com/yiisoft/yii2/issues/11546","id":154252316,"number":11546,"title":"Dependency of input ids into the whole framework","user":{"login":"ericmaicon","id":1010637,"avatar_url":"https://avatars.githubusercontent.com/u/1010637?v=3","gravatar_id":"","url":"https://api.github.com/users/ericmaicon","html_url":"https://github.com/ericmaicon","followers_url":"https://api.github.com/users/ericmaicon/followers","following_url":"https://api.github.com/users/ericmaicon/following{/other_user}","gists_url":"https://api.github.com/users/ericmaicon/gists{/gist_id}","starred_url":"https://api.github.com/users/ericmaicon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericmaicon/subscriptions","organizations_url":"https://api.github.com/users/ericmaicon/orgs","repos_url":"https://api.github.com/users/ericmaicon/repos","events_url":"https://api.github.com/users/ericmaicon/events{/privacy}","received_events_url":"https://api.github.com/users/ericmaicon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-11T14:05:54Z","updated_at":"2016-05-11T14:05:54Z","closed_at":null,"body":"Imagine that your application request two tabs of the same form. The system also has a button that add more tabs as the user will using it. \r\n\r\n**_tab.php**\r\n~~~php\r\n<?php $form = ActiveForm::begin([\r\n...\r\n]); ?>\r\n    <div class=\"row\">\r\n        <div class=\"col-sm-3\">\r\n            <?= $form->field($model, 'first_name')->textInput(['maxlength' => true]) ?>\r\n       </div>\r\n    </div>\r\n<?php ActiveForm::end();?>\r\n~~~\r\n\r\nBearing this in mind, because of the following code, it will reproduce an HTML with duplicated ids:\r\n\r\n**BaseHtml.php**\r\n~~~php\r\npublic static function activeInput($type, $model, $attribute, $options = [])\r\n    {\r\n        $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);\r\n        $value = isset($options['value']) ? $options['value'] : static::getAttributeValue($model, $attribute);\r\n        if (!array_key_exists('id', $options)) {\r\n            $options['id'] = static::getInputId($model, $attribute);\r\n        }\r\n        return static::input($type, $name, $value, $options);\r\n    }\r\n~~~\r\n\r\n**output:**\r\n~~~html\r\n<input type=\"text\" id=\"personsearch-first_name\" class=\"form-control\" name=\"PersonSearch[first_name]\" maxlength=\"45\">\r\n~~~\r\n\r\nHaving a simple input with duplicated id is not the problem, but when you start to work with JS (MaskInput widget, datepicker...) it become a mess.\r\n\r\n**InputWidget.php**\r\n~~~php\r\npublic function init()\r\n    {\r\n        if ($this->name === null && !$this->hasModel()) {\r\n            throw new InvalidConfigException(\"Either 'name', or 'model' and 'attribute' properties must be specified.\");\r\n        }\r\n        if (!isset($this->options['id'])) {\r\n            $this->options['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId();\r\n        }\r\n        parent::init();\r\n    }\r\n~~~\r\n\r\nEverything on the framework seems to be related to the id. Since the one of the ideas of a framework is to be abstract and let the user free to do anything, it shouldn't be so rigid, right?\r\n\r\nI tried to override some classes (ActiveForm, ActiveField, HTML, MaskedInput.....) to treat it on my system, but it started to become a huge solution for a small problem. Besides, it didn't solve the problem and created others: JS validator stop working for e.g.\r\n\r\nI guess not, since I checked the core code, but I would like to know if there is a solution to it without change my system logic (I researched here and didn't find for a duplicated issue). If not, I would like to know if someone had the same thought and if the core team is thinking about a solution to it.\r\n\r\nThank you in advance.\r\n\r\n### Additional info\r\n\r\n| Q                | A\r\n| ---------------- | ---\r\n| Yii version      |  2.0.8\r\n| PHP version      |  5.6.21\r\n| Operating system | Boot2Docker 1.11.1 (TCL 7.0); HEAD : 7954f54 - Wed Apr 27 16:36:45 UTC 2016\r\n"}}