Answer the question
In order to leave comments, you need to log in
How do I group a list in a static table?
I need to do to group all the value, but the value from the table that I displayed, it is important to add a link to the record there, but for the link I need an id, which cannot be displayed in ArrayHelper.map.
Here is my implementation
In Controller
public function actionIndex()
{
$users = User::find()->all();
$users = ArrayHelper::map($users, 'nameEmployee', 'salary', 'position.name');
return $this->render('index', compact('users'));
}
<?php foreach ($users as $key => $user){
echo '<tr><td colspan="2"><strong>'.$key.'</strong></td></tr>';
foreach ($user as $name => $salary) {
echo '<tr>';
echo '<td>'.$name.'</td>';
echo '<td>'.$salary.' рублей</td>';
echo '</tr>';
}
} ?>
Answer the question
In order to leave comments, you need to log in
The question is asked in such a way that nothing is clear. So let's guess. You are probably trying to group an array, but for some reason decided to use the map method, which is not intended for this. I understand you need the index method:
www.yiiframework.com/doc-2.0/guide-helper-array.ht...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question