Download the PHP package studio255/yii2-jstree without Composer
On this page you can find all versions of the php package studio255/yii2-jstree. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download studio255/yii2-jstree
More information about studio255/yii2-jstree
Files in studio255/yii2-jstree
Package yii2-jstree
Short Description Yii2 widget wrapping the jsTree jQuery library — displays and manages ActiveRecord models as interactive trees.
License MIT
Homepage https://github.com/studio255/yii2-jstree
Informations about the package yii2-jstree
yii2-jstree
A Yii2 widget for the jsTree jQuery library — display and manage Yii2 ActiveRecord models as interactive trees.
Features
- Load tree data via AJAX
- Custom icons per node type (FontAwesome, Bootstrap Icons, or any CSS class)
- Context menu: create, rename, duplicate, delete
- Drag-and-drop reordering
- Submenu with individual node types
- Dynamic context menu — hide items per node type (e.g. no delete on type page)
- Customizable labels and confirmation messages
- Yii2 validation errors forwarded to JavaScript alerts
Requirements
- PHP 8.2 or higher
- Yii2 2.0.51 or higher
Installation
Usage
Simple variant — JSON URL only
Full variant — backed by a Yii2 ActiveRecord model
Enables create, move, rename and delete operations on the model directly from the tree.
Required model / database fields:
| Field | Required | Purpose |
|---|---|---|
name |
yes | Display label |
parent_id |
yes | Tree nesting |
position |
yes | Sort order within parent |
type |
no | Used for icon and permission handling |
Important: Only
nameshould be a required attribute in your model — otherwise the New context menu action may fail.
Controller setup:
View setup:
A click on a tree item triggers the update action via AJAX and loads the result into .jstree-result. Forms used inside the result div should carry the class jstree-form so their submit response is routed back to the result container.
The icon classes in the examples use FontAwesome — any CSS-based icon set works (Bootstrap Icons, Material, custom classes).
Demo
A working demo setup is available in the demo/ directory.
License
MIT — see LICENSE.