Display data with a for each loop

Currently I am displaying categories in a dropdown list using getCategoryList function in my model.

Current code

 <?= $form->field($model, 'category')->dropDownList($model->categoryList,[

'prompt'=>'Select Category to view',


]) ?>

However I want to do display them as link with the id as the href and name as the text between the link tags.

I tried the following however this just echo the category name


foreach($model->categoryList as $cat){

    echo $cat;



Using var dump I get

array(3) { [1]=> string(7) "Economy" [2]=> string(7) "Society" [3]=> string(5) "Sport" }

what is $model->categoryList? Is it a function? if so post it.

once you post it I can give you a definite answer.

$model->categoryList->name …whatever the cat value is called.

This is the function in my model

    public function getCategoryList()


        $statusArray = [

            self::CATEGORY_ECONOMY => Yii::t('app', 'Economy'),

            self::CATEGORY_SOCIETY => Yii::t('app', 'Society'),

            self::CATEGORY_SPORT   => Yii::t('app', 'Sport'),


        return $statusArray;