namespace app\components;
use Yii;
use yii\helpers\Html;
class Common
{
public static function transarray($array) {
foreach ($array as $key => $value) {
$array[$key] = Yii::t('stz', $value);
}
return $array;
}
}
and then my new code become:
$dataList= Common::transarray(ArrayHelper::map(ProfileCat::find()->orderBy('order')->all(),'id','description'));
echo $form->field($profile, 'cat')->dropDownList($dataList,
['prompt'=>Yii::t('stz','-Choose a Category-')]) ;
I don’t know if there’s a better method but at the moment form me it works fine.