S
S
sdgs4s4 .2017-10-23 09:26:22
Yii
sdgs4s4 ., 2017-10-23 09:26:22

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

1 answer(s)
D
Dmitry Bay, 2017-10-23
@Encoderast

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 question

Ask a Question

731 491 924 answers to any question