Area content widgets for Yii2
The widget can, Duplicate area by clicking the button, (*1)
Preview
, (*2)
Installation
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
php composer.phar require --prefer-dist kak/area "*"
or add, (*5)
"kak/area": "*"
to the require section of your composer.json
file., (*6)
Once the extension is installed, simply use it in your code by:, (*7)
'add params',
'items' => [
['key' => 'key.name'],
['key' => 'key.name1'],
['key' => 'key.name2' , 'value' => '2'],
['key' => 'key.name3'],
]
]);?>
<div class="row form-group">
<div class="col-xs-1">
<button type="button" class="btn btn-danger" role="area.remove" >-</button>
</div>
<div class="col-xs-4">
<input type="text" name="params[key][]" placeholder="Key" value="{%=o.key%}" class="form-control"/>
</div>
<div class="col-xs-4">
<input type="text" name="params[value][]" placeholder="Value" value="{%=o.value%}" class="form-control"/>
</div>
</div>
Once the extension is installed, simply use it in your code by:, (*8)
<?php
$models = PostParams::findOne($id);
kak\widgets\area\Area::widget([
'item' => new PostParams,
'items' => $models,
'viewParams' => [
'form' => $form
],
'viewItem' => '@app\views\post\_item-post-param'
]);
viewItem is closure function support, (*9)
<?php
kak\widgets\area\Area::widget([
'item' => new PostParams,
'items' => $models,
'viewParams' => [
'form' => $form
],
'viewItem' => function($params, $thisArea){
},
]);
Class Area
@package kak\widgets\area, (*10)
public buttonLabel
string text button, (*11)
public buttonOptions
array html options button add item, (*12)
public viewItem
String|Closure render view file templated, (*13)
public viewParams
array addintion view params, (*14)
public template
string template btn layout, (*15)
public item
array default item or model, (*16)
public items
array data array or models, (*17)
public itemOptions
array html options block item, (*18)
public label
string text label, (*19)
public labelOptions
array html options label, (*20)