Warp Tree demo — trees of departments and categories for Filament: choose, filter, edit by dragging. Change or delete anything; the data is reset every hour. warpui.com About Warp Tree Docs Ask a question Support
Skip to content

Checkboxes on a tree

CheckboxTree shows the tree inside the form, with a checkbox on every item: for permissions, for who may see something, for whom to notify. Nothing on this page is saved.

A parent with three states

CheckboxTree::make('departments')->tree(Department::class): checking a parent checks everything under it. A parent is checked when everything under it is, shows a dash when only some of it is, and is empty otherwise.

Note: Try it

The field starts with the Boston office and its three teams checked, so Sales has a dash. Open Sales, then East: East has a dash too, and Boston is checked. Check New York: its three teams are checked with it. Open Boston and uncheck Inside sales: Boston turns from checked to a dash. Then press “Show what would be saved”: it lists the ids of the checked departments (the form saves ids, not names).

Departments that may see the report

Each item on its own

->cascade(false) checks only the item you click. A dash on a parent then means: something under it is checked.

Note: Try it

Open Sales and check East: only East is checked, and Sales gets a dash. Open East: its offices are still unchecked. Check Boston, then uncheck East: Boston stays checked, and East now shows a dash.

Departments to notify

A tree written as an array

->tree([...]) takes the items from an array, for example permissions grouped by area. What is saved are the keys of the array.

Note: Try it

Check Orders: View, Edit and Delete under it are checked too. Uncheck Delete: Orders shows a dash. “Show what would be saved” lists the keys, such as orders.view.

Permissions of the role