Answer the question
In order to leave comments, you need to log in
What to wrap helper in foreach -> Yii2?
Hello! Tell me how to wrap
\yii\helpers\Url::to(['product/view', 'id' => $product->id]);
to make it work?foreach($products as $product) {
echo'<a href="';
\yii\helpers\Url::to(['product/view', 'id' => $product->id]);
echo"</ a>";
?>
Answer the question
In order to leave comments, you need to log in
forgot echo?
In general, there are structures specifically for this:
foreach($products as $product) {
echo Html::a('link',['product/view', 'id' => $product->id],['class'='class1']);
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question