P
P
prohorow02020-06-19 06:59:45
Yii
prohorow0, 2020-06-19 06:59:45

How to fix Using $this when not in object context error?

<?php
/* @var $this yii\web\View */
use yii\helpers\Html;
$this->title = 'My Yii Application';
?>
<div class="site-index">
<div class="body-content">
<div class="row">
<?php
foreach ($request as $req) { ?>
<div class="col-lg-6">
<h3><?= Html::encode("{$req->h1}") ?></h3>
<h5><?= Html::encode("{$req->content}") ?></h5>
<?php
if ($req->count != 0) {
?>
<h4><?= Html::encode("На складе {$req->count}") ?></h4>
<?php } else { ?>
<h4>Нет на складе</h4>
<?php }
?>
<span><h3><?= Html::encode("Цена {$req->price} Р") ?></h3></span>
<?php $form = \yii\widgets\ActiveForm::begin(); ?>
<?php
if ($req->count > 0 && !Yii::$app->user->isGuest) {
?>
<input name="buy" style="float: right;margin-bottom: 20px;" type="submit" class="btn btn-primary"
value="Добавить в корзину">
<input type="hidden" value="<?= $req->id ?>" name="id">
<input name="more" style="float: right; margin-right: 5px; margin-bottom: 20px;"
type="submit" class="btn btn-primary" value="Подробнее">
<?php
} else { ?>
<input type="hidden" value="<?= $req->id ?>" name="id">
<input name="more" style="float: right; margin-right: 5px; margin-bottom: 20px;"
type="submit" class="btn btn-primary" value="Подробнее">
<?php }
\yii\widgets\ActiveForm::end() ?>
</div>
<?php }
?>
</div>
</div>
</div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question