How to show details in index table

Hello all,

I have managed to pass value in my _form into a dropdown menu like this:

<?= $form->field($model, ‘categories’)->dropDownList(

    ArrayHelper::map(Categories::find()-&gt;all(),'categories','categories'),


    ['prompt'=&gt;'Select a category']


) ?&gt;

But I cannot manage to pass the values into my Posts model grid table.

I have 2 tables, one called posts, one called categories, I have linked them as "many to many"

$this->hasMany(CategoriesHasPosts::className(), [‘posts_id’ => ‘id’]);

Right now when I fill in the form from the post view, it shows the dropdown menu right with all the categories, how to then show these categories in all the other views of the post model please?

Thank you,

Ben