I want to add a pop up inside video/view.php(similar to youtube when you watch a video), and when you click on "Add to Playlist" to display playlist/create.phpand add a playlist. The problem is that "playlist" is outside the scope of "video" and it doesnt detect what $this is or anything really.
Is there a way to do this, using the incorporated create action inside playlist?
I am using a video/_buttons.php to do the buttons inside video/view.php
_buttons.php which have like,dislike and "add to playlist" button
<?php
use yii\helpers\Url;
?>
<a href="<?php echo Url::to(['/video/like', 'id' => $model->video_id]) ?>"
class="btn btn-sm <?php echo $model->isLikedBy(Yii::$app->user->id) ? 'btn-outline-primary': 'btn-outline-secondary' ?>"
data-method="post" data-pjax="1">
<i class="fas fa-thumbs-up"></i> <?php echo $model->getLikes()->count() ?>
</a>
<a href="<?php echo Url::to(['/video/dislike', 'id' => $model->video_id]) ?>"
class="btn btn-sm <?php echo $model->isDislikedBy(Yii::$app->user->id) ? 'btn-outline-primary': 'btn-outline-secondary' ?>"
data-method="post" data-pjax="1">
<i class="fas fa-thumbs-down"></i> <?php echo $model->getDislikes()->count() ?>
</a>
<a class="btn btn-sm <?php echo 'btn-outline-secondary' ?>"
id="myBtn">Add to Playlist</a>
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p>Here i want to create a playlist item</p>
</div>
</div>
The way the buttons are implemented in video/view.php
<div>
<?php \yii\widgets\Pjax::begin() ?>
<?php echo $this->render('_buttons', [
'model' => $model
]) ?>
<?php \yii\widgets\Pjax::end() ?>
</div>
And the action "create" in playlist/create
<?php
use yii\helpers\Html;
$this->title = 'Create Playlist';
$this->params['breadcrumbs'][] = ['label' => 'Playlists', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="playlist-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
Any help is usefull!