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

A tree inside a form

TreeBuilder is a field for a small tree that belongs to the record being edited: the links of a menu, the chapters of a manual, the parts of a product. The whole tree is saved with the form. Nothing on this page is saved.

A tree saved as a nested array

TreeBuilder::make('links')->schema([...]) saves the tree as a nested array, ready for a JSON column. schema() is the form for adding and editing an item, and itemDescription() puts a second line under the name (here the link).

Note: Try it

Drag Contact by its handle to the upper edge of Home (a line shows where it will land), then drop Tools onto the middle of Contact (a frame appears) to put it inside. Press + on Products to add an item under it, the pencil to change a name or a link, and the bin on Products: because it has items under it, it asks first. Then press “Show what would be saved”.

  • Home /
  • Products /products 2
    • Fasteners /products/fasteners
    • Tools /products/tools
  • Contact /contact

Drag an item by its handle to change the order, or drop it on another item to put it inside. With the keyboard: select an item and press Alt and the arrow keys.

A tree with a depth limit

->maxDepth(2) keeps the tree to two levels. Without schema(), an item has only a name.

Note: Try it

Getting started has + to add a chapter under it; Install and First order, on level 2, have none. Drop Returns onto Install: it lands beside Install, not inside it. Drop Getting started onto Returns: nothing moves, because its chapters would end up on level 3.

  • Getting started 2
    • Install
    • First order
  • Returns

Drag an item by its handle to change the order, or drop it on another item to put it inside. With the keyboard: select an item and press Alt and the arrow keys.