kak/area

area container widgets for Yii2

v1.0.0 2017-09-22 11:19 UTC

This package is auto-updated.

Last update: 2024-04-05 22:27:37 UTC


README

The widget can, Duplicate area by clicking the button Preview

68747470733a2f2f6c68332e676f6f676c6575736572636f6e74656e742e636f6d2f2d473642424b6879517156672f566130436d745736762d492f41414141414141414143672f466e555f516339447969552f733531322d496334322f61726561507265766965772e706e67

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist kak/area "*"

or add

"kak/area": "*"

to the require section of your composer.json file.

Usage area widget

Once the extension is installed, simply use it in your code by:

<?php kak\widgets\area\Area::begin([
        'label' => '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>
<?php kak\widgets\area\Area::end();?>

Usage area widget render template file

Once the extension is installed, simply use it in your code by:

<?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

<?php
 kak\widgets\area\Area::widget([
     'item' => new PostParams,
     'items' => $models,
     'viewParams' => [
         'form' => $form
     ],
     'viewItem' => function($params, $thisArea){
        
     },
 ]);   

kak\widgets\area\Area

Class Area @package kak\widgets\area

public buttonLabel string text button

public buttonOptions array html options button add item

public viewItem String|Closure render view file templated

public viewParams array addintion view params

public template string template btn layout

public item array default item or model

public items array data array or models

public itemOptions array html options block item

public label string text label

public labelOptions array html options label