PHP code example of wonail / yii2-widget-nestable

1. Go to this page and download the library: Download wonail/yii2-widget-nestable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wonail / yii2-widget-nestable example snippets


// 数据库里保存的数据,这里用json格式保存,部件读取时,直接decode解码即可
$value = '[{"group":"disable","title":"禁用","items":[]},{"group":"enable","title":"启用","items":[{"title":"修改头像","name":"change_avatar","id":1},{"title":"选择个人标签","name":"set_tag","id":3},{"title":"填写扩展资料","name":"expand_info","id":2}]}]';
echo $form->field($model, 'name')->widget(\wonail\nestable\Nestable::className(), [
    'items' => \yii\helpers\Json::decode($value),
    'pluginOptions' => [
        'group' => 1,
        'maxDepth' => 1
    ]
]);

php composer.phar