mdmsoft / yii2-widgets
Yii2小部件
1.4
2020-10-20 05:29 UTC
Requires
- yiisoft/yii2: ~2.0.4
This package is not auto-updated.
Last update: 2024-09-17 23:55:38 UTC
README
安装
安装此扩展的首选方式是通过 Composer。
运行以下命令之一:
php composer.phar require mdmsoft/yii2-widgets "~1.0"
或者将以下内容添加到您的 composer.json
文件的 require 部分:
"mdmsoft/yii2-widgets": "~1.0"
to the require section of your composer.json
file.
用法
TabularInput 小部件
_form.php
<?php $form = ActiveForm::begin()?> <table class="table"> <thead> <tr> <th> </th> <th> </th> <th><a id="btn-add"><span class="glypicon glypicon-plus"></span></a></th> </tr> </thead> <?= TabularInput::widget([ 'id' => 'detail-grid', 'allModels' => $model->items, 'model' => OrderItem::className(), 'tag' => 'tbody', 'form' => $form, 'itemOptions' => ['tag' => 'tr'], 'itemView' => '_item_detail', 'clientOptions' => [ 'btnAddSelector' => '#btn-add', ] ]); ?> </table>
_item_detail.php
<td><?= $form->field($model,"[$key]product_id")->textInput()->label(false); ?></td> <td><?= $form->field($model,"[$key]qty")->textInput()->label(false); ?></td> <td><a data-action="delete"><span glypicon glypicon-minus></span></a></td>
GridInput 小部件
<?= GridInput::widget([ 'id' => 'detail-grid', 'allModels' => $model->items, 'model' => OrderItem::className(), 'columns' => [ ['class' => 'mdm\widgets\SerialColumn'], 'product_id', 'qty', [ 'attribute' => 'uom_id', 'items' => [ 1 => 'Pcs', 2 => 'Dozen' ] ], [ 'attribute' => 'tax', 'type' => 'checkbox', ], ['class' => 'mdm\widgets\ButtonColumn'] ], ]); ?>