prawee/yii2-widgets

yii2 widgets alert

Installs: 1 379

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 5

Open Issues: 0

Type:yii2-extension

1.0.0 2019-07-21 07:54 UTC

This package is auto-updated.

Last update: 2024-04-23 15:14:45 UTC


README

The extends class for all widgets classes on views

contains

  • ButtonAjax for make ajax button for showing modal
  • LinkAjax for make ajax link for showing modal

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist prawee/yii2-widgets "dev-master"

or add

"prawee/yii2-widgets": "dev-master"

to the require section of your composer.json file.

Usage

ButtonAjax | LinkAjax

on your views

use prawee\widgets\ButtonAjax;
use yii\bootstrap\Modal;

echo ButtonAjax::widget([
    'name'=>'Create',
    'route'=>['create'],
    'modalId'=>'#main-modal',
    'modalContent'=>'#main-content-modal',
    'options'=>[
        'class'=>'btn btn-success',
        'title'=>'Button for create application',
    ]
]);
...
Modal::begin(['id'=>'main-modal']);
echo '<div id="main-content-modal"></div>';
Modal::end();

on your controller

public functionn actionCreate(){
    ...
    if(Yii::$app->getRequest()->isAjax){
        return $this->renderAjax('create', [
            'model' => $model,
        ]);
    }else{
        return $this->render('create', [
            'model' => $model,
        ]);
    }
}