conquer / modal
Extension for the Yii2 framework
Installs: 17 628
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 4
Forks: 10
Open Issues: 2
Language:JavaScript
Type:yii2-extension
Requires
- yiisoft/yii2: >=2.0.4
README
Description
This extension allows you to quickly add full-featured modal forms to your appllication. Main featues are:
- Based on bootstrap modal forms.
- Allows quickly add behavior to interact with viewing and updating data in modal dialogs.
- Catch form post events, converts them to ajax request and display results in the same modal dialog.
Installation
The preferred way to install this extension is through composer.
To install, either run
$ php composer.phar require conquer/modal "*"
or add
"conquer/modal": "*"
to the require
section of your composer.json
file.
Usage
Somewhere in the main layout
\conquer\modal\ModalForm::widget([ 'selector' => '.modal-form', ]);
Whenever you want to add behavior to tag a, just add class 'modal-form'
echo Html::a('Some modal action', ['controller/action'], ['class' => 'modal-form']);
To improve traffic data and error exceptions you need to control layout rendering when ajax requests. I recommend you to override default rendering in your controllers:
class Controller extends \yii\web\Controller { /** * Exclude layout rendering when ajax requests */ public function render($view, $params = []) { if (\Yii::$app->request->isAjax) { return $this->renderPartial($view, $params); } return parent::render($view, $params); } }
Client Options
To add client options use clientOptions
key. Available client options are: id
, class
, tabindex
.
- Id key replaces existing auto generated id attribute.
- Class key adds classes to html class attribute.
- Tabindex key replaces existing default tabindex html attribute (-1), when false, then no tabindex attribute appears.
\conquer\modal\ModalForm::widget([
'selector' => '.modal-form',
'clientOptions' => [
'id' => 'sample-unique-id',
'class' => 'sample-class1 sample-class2',
'tabindex' => false
]
]);
License
conquer/modal is released under the MIT License. See the bundled LICENSE
for details.