{"action":"opened","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/9019","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/9019/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/9019/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/9019/events","html_url":"https://github.com/yiisoft/yii2/issues/9019","id":93236796,"number":9019,"title":"How to add non clickable/selectable text in dropdownlist yii2","user":{"login":"maheshtc","id":9860829,"avatar_url":"https://avatars.githubusercontent.com/u/9860829?v=3","gravatar_id":"","url":"https://api.github.com/users/maheshtc","html_url":"https://github.com/maheshtc","followers_url":"https://api.github.com/users/maheshtc/followers","following_url":"https://api.github.com/users/maheshtc/following{/other_user}","gists_url":"https://api.github.com/users/maheshtc/gists{/gist_id}","starred_url":"https://api.github.com/users/maheshtc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maheshtc/subscriptions","organizations_url":"https://api.github.com/users/maheshtc/orgs","repos_url":"https://api.github.com/users/maheshtc/repos","events_url":"https://api.github.com/users/maheshtc/events{/privacy}","received_events_url":"https://api.github.com/users/maheshtc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-06T09:52:33Z","updated_at":"2015-07-06T09:52:33Z","closed_at":null,"body":"I am trying to display user's list in dropdownlist. Here, I want to display user's role as label, so that listing looks like users grouping based on user's role. It becomes easy for selection to end user.\r\n\r\n<?= $form->field($model, 'user_id')->dropDownList(\\yii\\helpers\\ArrayHelper::map(\\common\\models\\Users::getUsersList(),'id','name')\r\n            'id',\r\n            'user_name'\r\n        ), ['prompt'=>'Select ']) ?>\r\n\r\npublic static function getUsersList(){\r\n        $data =[];\r\n        $roles = UserRoles::find()->where(['status'=>1])->all();\r\n        foreach($roles as $role){\r\n            $data[] = ['id'=>'','name'=>'<label>'.$role->role_name.'</label>'];\r\n            $users  = Users::find()->where(['status'=>1,'role_id'=>$role->role_id])->all();\r\n            foreach($users as $user){\r\n                $data [] = ['id'=>$user->id,'name'=>$user->user_name];\r\n            }\r\n        }\r\n        return $data;\r\n    }\r\n\r\nSuggest How Can I add label. "}}