Dropdownlist in yii

Hello i am using a dropdownlist in a form and it works correctly but when i send the information to in the gridView it shows me only the id of the selection and i wnat to show the text of the selection. How can i do it?


my form
<?php $form = ActiveForm::begin([‘options’ => [‘enctype’=>‘multipart/form-data’]]); ?>

<?php echo $form->field($model, ‘tipo’)->dropDownList(ArrayHelper::map( tipo::find()->all(), ‘id’, ‘tipo’), [‘id’=>‘tipo’]);?>

<?=$form->field($model, ‘departamento’)->dropDownList(ArrayHelper::map( departamento::find()->all(), ‘id’, ‘departamento’), [‘id’=>‘departamento’]);?>

<?= $form->field($model, ‘descripcion’)->textInput([‘maxlength’ => true]) ?>

my index

<?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'id', 'tipo', 'departamento', 'descripcion', 'estatus', 'Imagen',

@EdgarBaeza13 you can update your gridview's column like

tipo, // replace this field with below
[
    'attribute' => 'tipo',
    'filter' => ArrayHelper::map(tipo::find()->all(), 'id', 'tipo'),
    'value' => function ($model) {
        return $model->{tipo relation}->tipo;
    },
],

and so on for other fields.

Please have a look at this guide https://www.yiiframework.com/doc/guide/2.0/en/output-data-widgets

You can find other options for data columns here https://www.yiiframework.com/doc/api/2.0/yii-grid-datacolumn

Recommendation : Please have a look at the PSR1 and PSR2. https://www.php-fig.org/psr/