{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/11423","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/11423/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/11423/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/11423/events","html_url":"https://github.com/yiisoft/yii2/issues/11423","id":150998470,"number":11423,"title":"CompareValidator client side validation not working with specific IDs","user":{"login":"gael-wogenstahl","id":5624541,"avatar_url":"https://avatars.githubusercontent.com/u/5624541?v=3","gravatar_id":"","url":"https://api.github.com/users/gael-wogenstahl","html_url":"https://github.com/gael-wogenstahl","followers_url":"https://api.github.com/users/gael-wogenstahl/followers","following_url":"https://api.github.com/users/gael-wogenstahl/following{/other_user}","gists_url":"https://api.github.com/users/gael-wogenstahl/gists{/gist_id}","starred_url":"https://api.github.com/users/gael-wogenstahl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gael-wogenstahl/subscriptions","organizations_url":"https://api.github.com/users/gael-wogenstahl/orgs","repos_url":"https://api.github.com/users/gael-wogenstahl/repos","events_url":"https://api.github.com/users/gael-wogenstahl/events{/privacy}","received_events_url":"https://api.github.com/users/gael-wogenstahl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-25T22:35:22Z","updated_at":"2016-04-26T10:03:59Z","closed_at":null,"body":"I found this issue while using the `CompareValidator`between 2 attributes when the attribute to be compared to has a specific ID.\r\n\r\nIn my model I have two attributes `A` and `B` and I setup a `compare` validator on attribute `B` to be greater than attribute `A`.\r\nIn my view I use a specific ID for my attribute `A`.\r\n\r\nWhen client side validation is triggered I get an error no matter what the value of input `B` is.\r\n\r\nDigging into the PHP and Javascript code I found out that:\r\n- In `yii.validation.js` on line 289 the following code would not return the value of attribute to compare to `compareValue = $('#' + options.compareAttribute).val();`\r\n- In `CompareValidator.php` on line 222 the initialisation of `compareAttribute` in `options` table is done through the `Html::getInputId` method instead of using the specific ID provided\r\n\r\nBeing not as talented and expert as you guys on the Yii2 framework I have no clue how to solve that problem if it is solvable in any way.\r\nCan you help ?\r\n\r\n| Q                | A\r\n| ---------------- | ---\r\n| Yii version      | 2.0.8-dev\r\n| PHP version      | 5.5.9-1ubuntu4.14\r\n| Operating system | Ubuntu Server 14.04"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/214691028","html_url":"https://github.com/yiisoft/yii2/issues/11423#issuecomment-214691028","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/11423","id":214691028,"user":{"login":"SilverFire","id":4499203,"avatar_url":"https://avatars.githubusercontent.com/u/4499203?v=3","gravatar_id":"","url":"https://api.github.com/users/SilverFire","html_url":"https://github.com/SilverFire","followers_url":"https://api.github.com/users/SilverFire/followers","following_url":"https://api.github.com/users/SilverFire/following{/other_user}","gists_url":"https://api.github.com/users/SilverFire/gists{/gist_id}","starred_url":"https://api.github.com/users/SilverFire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilverFire/subscriptions","organizations_url":"https://api.github.com/users/SilverFire/orgs","repos_url":"https://api.github.com/users/SilverFire/repos","events_url":"https://api.github.com/users/SilverFire/events{/privacy}","received_events_url":"https://api.github.com/users/SilverFire/received_events","type":"User","site_admin":false},"created_at":"2016-04-26T10:03:59Z","updated_at":"2016-04-26T10:03:59Z","body":"Related to https://github.com/yiisoft/yii2/issues/9811\r\nClosing as a duplicate"}}