esto va en el modelo este es un ejemplo con Monedas public static function Lista() { $s = \yii\helpers\ArrayHelper::map(Monedas::find() /* ->andWhere(['id_sector' => 2]) */ ->orderBy('id_moneda') ->all(), 'id_moneda', 'nombre_moneda'); return ($s) ? $s : []; } y en el index quedaria asi: 'id_moneda' => [ 'attribute' => 'id_moneda', 'headerOptions' => ['style' => 'text-align:center;'], 'contentOptions' => ['style' => 'text-align:center; width:2%; vertical-align:middle;'], 'label' => 'Moneda', // Cambia la etiqueta según sea necesario 'filter' => app\models\Monedas::lista(), // Asegúrate de que este método exista en tu modelo 'value' => function ($data) { $moneda = app\models\Monedas::find()->where(['id_moneda' => $data->id_moneda])->one(); return ($moneda) ? $moneda->nombre_moneda : ''; // Cambia 'nombre_moneda' al atributo correcto }, ],
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter