Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/biladina/yii2-ajaxcrud

Yii2 Ajax CRUD with Boostrap 4/5. Previously https://github.com/johnitvn/yii2-ajaxcrud
https://github.com/biladina/yii2-ajaxcrud

ajax boostrap4 bootstrap bootstrap-5 bootstrap5 crud crud-generator gii yii2 yii2-ajaxcrud yii2-ajaxcrud-bs5

Last synced: about 2 months ago
JSON representation

Yii2 Ajax CRUD with Boostrap 4/5. Previously https://github.com/johnitvn/yii2-ajaxcrud

Awesome Lists containing this project

README

        

yii2-ajaxcrud
=============

Original work by [johitvn](https://github.com/johnitvn/yii2-ajaxcrud).

But we need to work with Bootstrap 4, so we create this repository. If [johitvn](https://github.com/johnitvn/yii2-ajaxcrud) update his repo, we will delete this repository.

[![Latest Stable Version](https://poser.pugx.org/johnitvn/yii2-ajaxcrud/v/stable)](https://packagist.org/packages/johnitvn/yii2-ajaxcrud)
[![License](https://poser.pugx.org/johnitvn/yii2-ajaxcrud/license)](https://packagist.org/packages/johnitvn/yii2-ajaxcrud)
[![Total Downloads](https://poser.pugx.org/johnitvn/yii2-ajaxcrud/downloads)](https://packagist.org/packages/johnitvn/yii2-ajaxcrud)

Gii CRUD template for Single Page Ajax Administration for yii2

index

create

view

update

delete

Features
------------
+ Create, read, update, delete in onpage with Ajax
+ Bulk delete suport
+ Pjax widget suport
+ Export function(pdf,html,text,csv,excel,json)
+ Support Boostrap 4/5
+ Added translations, available right now only English and Indonesia
+ Reload multiple Pjax

Installation
------------

The default installation is using Bootstrap 5.

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist biladina/yii2-ajaxcrud-bs4 "~3.0"
```

or add

```
"biladina/yii2-ajaxcrud-bs4": "~3.0"
```

to the require section of your `composer.json` file.

Bootstrap 4
------------
If you still need the Boostrap 4 version, you can use version 2

```
php composer.phar require --prefer-dist biladina/yii2-ajaxcrud-bs4 "~2.0"
```

or add

```
"biladina/yii2-ajaxcrud-bs4": "~2.0"
```

to the require section of your `composer.json` file.

Usage
-----
For first you must enable Gii module Read more about [Gii code generation tool](http://www.yiiframework.com/doc-2.0/guide-tool-gii.html)

Because this extension used [kartik-v/yii2-grid](https://github.com/kartik-v/yii2-grid) extensions so we must config gridview module before

Let's add into modules config in your main config file
```php
'modules' => [
'gridview' => [
'class' => '\kartik\grid\Module'
]
]
```

Add translation to the config
```php
'components' => [
'i18n' => [
'translations' => [
'yii2-ajaxcrud' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@yii2ajaxcrud/ajaxcrud/messages',
'sourceLanguage' => 'en',
],
]
]
]
```

Add `bsVersion` to the `params` file
```php
return [
'bsVersion' => '5.x',
];
```

You can then access Gii through the following URL:

http://localhost/path/to/index.php?r=gii

and you can see Ajax CRUD Generator

Translate
---------
Default translation is english, you can pull request new translation and you can change via config. Open your config `main.php`, change the language and translation `sourceLanguage`

Available Translation :
+ English
+ Indonesia

```php
'language' => 'id-ID',

'components' => [
'i18n' => [
'translations' => [
'yii2-ajaxcrud' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@yii2ajaxcrud/ajaxcrud/messages',
'sourceLanguage' => 'id',
],
]
]
]
```

Reload Multiple Pjax
--------------------
If you need to reload multiple GridView Pjax via Ajax respond from controller, you can add another Pjax ID separated by comma.

```php
return [
'forceReload'=>'#crud-pjax1,#crud-pjax2', // you can add more Pjax ID that you want to reload via ajax respond.
'title'=> Yii::t('yii2-ajaxcrud', 'Create New')." Content",
'content'=>''.Yii::t('yii2-ajaxcrud', 'Create').' Content '.Yii::t('yii2-ajaxcrud', 'Success').'',
'footer'=> Html::button(Yii::t('yii2-ajaxcrud', 'Close'), ['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"]).
Html::a(Yii::t('yii2-ajaxcrud', 'Create More'), ['create'],['class'=>'btn btn-primary','role'=>'modal-remote'])
];
```