Answer the question
In order to leave comments, you need to log in
How to properly use Pjax for links?
Good day. There is a page where you need to accept applications from users or reject them.
view:
<?php foreach ($members as $member): ?>
<?php if(($project->id == $member->project_id) && $member->status == 1): ?>
<?php Pjax::begin(); ?>
<?= $this->render('_waitmember', [
'project' => $project,
'member' => $member,
]) ?>
<?php Pjax::end(); ?>
<?php endif; ?>
<?php endforeach; ?>
<li><?= $member->user->username; ?></li>
<a class="btn btn-success"
href="<?= Url::to(['projects/accept', 'id' => $member->user->id, 'project_id' => $project->id]) ?>"
data-method="post" data-pjax="1">Принять
</a>
<a class="btn btn-danger"
href="<?= Url::to(['projects/reject', 'id' => $member->user->id, 'project_id' => $project->id]) ?>"
data-method="post" data-pjax="1">Отклонить
</a>
public function actionAccept($id, $project_id)
{
$project = $this->findProject($project_id);
$member = $project->isWaitingMember($id);
if($member) {
$member->status = 2;
$member->save();
}
return $this->renderAjax('_waitmember', [
'project' => $project,
'member' => $member,
]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question