I stuck with the problem while implementing the share with files functionality in my site.
Here the code in gridview:
...
[
'attribute' => 'description',
'enableSorting' => false,
],
[
'format' => 'raw',
'value' => function ($model) {
return ($model->shared ?
Html::a('<i style="color:red" class="glyphicon glyphicon-eye-open"></i>',['unshare', 'id'=>$model->id]) :
Html::a('<i class="glyphicon glyphicon-eye-close"></i>',['share', 'id'=>$model->id]))
.' '.Html::a('<i class="glyphicon glyphicon-download-alt"></i>',['download', 'id'=>$model->id])
.' '.Html::a('<i class="glyphicon glyphicon-pencil"></i>',['update', 'id'=>$model->id])
.' '.Html::a('<i class="glyphicon glyphicon-trash"></i>',['delete', 'id'=>$model->id])
.' '.Html::a('<i class="glyphicon glyphicon-link"></i>', '#', ['data-toggle'=>'modal', 'data-target'=>'#modalShare'] );
},
],
If I edit or view record I simply pass id in action like this:
Html::a('<i class="glyphicon glyphicon-pencil"></i>',['update', 'id'=>$model->id])
But I don't wanna go to another form located in another url path (e.g. update, view etc).
I wanna open boostrap modal and get access to the record id and name from the gridview inside modal. How to implement this?
I added:
Html::a('<i class="glyphicon glyphicon-link"></i>', '#', ['data-toggle'=>'modal', 'data-target'=>'#modalShare']
and this:
<!-- LinkModal -->
<div class="modal fade" id="modalShare" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Share with file <?=$searchModelAll->id ?> </h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
But I cannot get access to the id of the record. I undestand that writing <h4 class="modal-title" id="myModalLabel">Share with file <?=$searchModelAll->id ?> </h4>
is incorrect but I have no other ideas. Please help me.