Search code examples
phpyiiyii2yii-extensions

show or hide any forms by clicking a button using javascript in yii2


How to display the form when I click on Gridview button?

Basically I want to populate one form which includes the drop down and submit button in it.

By clicking on button I want to populate the form in popup box.

'panel' => [
        'type' => 'info',
        'after' => Html::button('<i class="glyphicon glyphicon-plus"></i>&nbsp;Allocate', [ 'id' => 'modalButton', 'class' => 'btn btn-success'),
        'showFooter' => false,

Solution

  • Used following code and resolved my issue.

     $this->registerJs("$(function() {
           $('#popupModal').click(function(e) {
             e.preventDefault();
             $('#modal').modal('show').find('.modal-content')
             .load($(this).attr('href'));
           });
        });");