Yii2 Ajax Modal
===============

[![Build Status](https://travis-ci.org/arthurfsilva/Yii2-Ajax-Modal.svg?branch=master)](https://travis-ci.org/arthurfsilva/Yii2-Ajax-Modal)


## Requirements
- Yii 2.0
- PHP >= 7.0

## Installation

You can use [Composer](http://getcomposer.org) to install.

- Download composer

- Either run <br>

```
php composer.phar require yac/ajax-modal "dev-master"
```

 or add in your composer.json <br>

 ```
 "yac/ajax-modal":"dev-master"
 ```

## Basic Usage

To use yii2 Ajax Modal you must make this:

```php
echo ajaxModal::widget([
    'button' =>[
      'text'=>'Modal Larger',
      'htmlOptions'=>['class'=>'btn btn-primary']
    ],
    'modal' => [
      'url' => Url::to(['site/contact']),
      'title' => 'My Modal',
      'button'=>[
        'save'=>Html::a('SAVE',['controller/action']),
        'cancel'=>Html::a('CANCEL',['controller/action'])
      ],

    ]
]);
```

## Advanced Usage

```php
echo ajaxModal::widget([
      'id'=>'myModal',
      'button'=> [
        'text'=>'Modal Larger',
        'htmlOptions'=>['class'=>'btn btn-primary']
      ],
      'modal'=>[
        'url' => Url::to(['site/contact']),
        'title' => 'Ola Mundo',
        'size' => ajaxModal::SIZE_LARGE,
        'loadSpin' => Html::img('images/loader.gif'),
        'buttons' => [
          'button1'=>Html::button('Cancel',['class'=>'btn btn-default','data-dismiss'=>'modal']),
          'button2'=>Html::submitButton('Save',['class'=>'btn btn-primary']),
        ],
        'type' =>  ajaxModal::FLAT,
        'modalOption' => []
      ]
  ])
  ```

## General Options

|     Option       |      Description                   |      Default Value     |
|---               |---                                 |---                     |
|  button          |  The button will be display on view|     null               |
|  modal           |  Modal basic implementation        |     array              |

### Modal Configuration

|     Option       |      Description                   |      Default Value     |
|---               |---                                 |---                     |
|  title           |  Title of modal                    |     empty              |
|  size            |  Size of modal                     |     4                  |
|  loadSpin        |  Loading animation                 |     <img src='images/loader.gif'> |
|  buttons         |  Buttons of modal                  |     save and cancel     |
|  type            |  type if you need modal flat or smooth|  smooth              |
|  backdropColor   |  color of backdrop                  |    black               |
|  modalOption     |  options like keyboard              |    array               |

size = EXTRA_LARGER | LARGER | MEDIUM | SMALL | EXTRA_SMALL <br/>
type = SMOOTH  | FLAT


## Report

- Report any issue [On the Github](https://github.com/arthurfsilva/Yii2-Ajax-Modal/issues)
