{"action":"closed","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/11372","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/11372/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/11372/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/11372/events","html_url":"https://github.com/yiisoft/yii2/issues/11372","id":148980988,"number":11372,"title":"Documentation for attributeLabels() in class yii\\base\\Model is ambiguous.","user":{"login":"vitalyspirin","id":7786743,"avatar_url":"https://avatars.githubusercontent.com/u/7786743?v=3","gravatar_id":"","url":"https://api.github.com/users/vitalyspirin","html_url":"https://github.com/vitalyspirin","followers_url":"https://api.github.com/users/vitalyspirin/followers","following_url":"https://api.github.com/users/vitalyspirin/following{/other_user}","gists_url":"https://api.github.com/users/vitalyspirin/gists{/gist_id}","starred_url":"https://api.github.com/users/vitalyspirin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitalyspirin/subscriptions","organizations_url":"https://api.github.com/users/vitalyspirin/orgs","repos_url":"https://api.github.com/users/vitalyspirin/repos","events_url":"https://api.github.com/users/vitalyspirin/events{/privacy}","received_events_url":"https://api.github.com/users/vitalyspirin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-17T18:48:11Z","updated_at":"2016-04-17T21:14:56Z","closed_at":"2016-04-17T21:14:56Z","body":"Currently yii\\base\\Model has the following implementation of attributeLabels():\r\n\r\n    public function attributeLabels()\r\n    {\r\n        return [];\r\n    }\r\n\r\n\r\nHowever comments for that function as well as documentation (http://www.yiiframework.com/doc-2.0/yii-base-model.html#attributeLabels()-detail) says:\r\n\"By default an attribute label is generated using generateAttributeLabel()\"\r\n\r\nI think it should be corrected to say something like this: \"By default this function returns an empty array. If you want to overload this function then you can use generateAttributeLabel().\"\r\n\r\nI am not sure why not to add implementation right into Model class:\r\n\r\n    public function attributeLabels()\r\n    {\r\n        $attributeLabelList = [];\r\n        foreach($this->attributes() as $attribute)\r\n        {\r\n            $attributeLabelList[$attribute] = \r\n                $this->generateAttributeLabel($attribute);\r\n        }\r\n        \r\n        return $attributeLabelList;\r\n    }\r\n\r\nActually as I see Gii uses more complicated algorithm to generate labels (it converts 'id' into 'ID' whereas generateAttributeLabel() converts it into 'Id'). Again, why wouldn't make it consistent?\r\n\r\nYii version 2.0.6.\r\n\r\nFile 'Model.php' (latest commit on Mar 22, 2016):\r\nhttps://github.com/yiisoft/yii2/blob/master/framework/base/Model.php#L287\r\n"}}