relbraun/yii2repeater
Composer 安装命令:
composer require relbraun/yii2repeater
包简介
Repeater widget for yii2 tabular
README 文档
README
An Yii2 widget enable you to implement Yii2 tabular with simple way.
##How to use
install using composer:
composer require relbraun/yii2repeater
put this code in your form:
<?php echo Repeater::widget([
'modelView' => '@backend/views/path/to/your/repeater_view_file',
'appendAction' => \yii\helpers\Url::to(['add-item-action']),
'removeAction' => \yii\helpers\Url::to(['remove-item-action']),
'form' => $form,
'models' => $models, //The existing sub models
]) ?>
in your desired controller ypu have to put tis code:
public function actions()
{
return [
'add-item' => [
'class' => 'relbraun\yii2repeater\actions\AppendAction',
'model' => 'backend\models\DesiredModel',
'contentPath' => '/path/to/repeater/view', //related to current controller
],
'remove-item' => [
'class' => 'relbraun\yii2repeater\actions\DeleteAction',
'model' => 'backend\models\DesiredModel',
]
];
}
And this is an example of the repeater_view_file.php reminded above:
<div class="repeater-content">
<div class="form-group">
<?= Html::label('Some label', Html::getInputId($model, "[$k]attribute")) ?>
<?= Html::activeTextInput($model, "[$k]attribute", ['class' => 'form-control']) ?>
</div>
<div class="form-group">
<?= Html::label('Other label', Html::getInputId($model, "[$k]other_attribute")) ?>
<?= Html::activeTextInput($model, "[$k]other_attribute", ['class' => 'form-control']) ?>
</div>
</div>
统计信息
- 总下载量: 4.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-27