@@ -24,48 +24,68 @@ composer require codewithdennis/filament-select-tree
2424## Usage
2525
2626``` PHP
27- use CodeWithDennis\FilamentSelectTree\SelectTree;
28- use App\Models\Category;
29-
27+ // Required to build a tree
3028SelectTree::make('category_id')
3129 // Creates a select tree with 'Category' model, using 'category_id' as parent and 'name' as label, allowing custom query modification.
3230 ->tree(Category::class, 'category_id', 'name', function ($query) {
3331 return $query;
3432 })
35-
36- // The label 'Category' is assigned to the field.
37- ->label(__('Category'))
38-
39- // Set a custom placeholder for when no items are selected
40- ->placeholder(__('Your custom placeholder here'))
41-
42- // Ensures that only leaf nodes can be selected while preventing the selection of groups.
43- ->disabledBranchNode()
44-
45- // Show the count of children alongside the group's name.
46- ->withCount()
47-
48- // To disable tags and display a text message instead (e.g., "X items have been selected")
49- // Tags is always disabled on single select
50- ->disableTags()
51-
52- // To keep the dropdown open at all times
53- ->alwaysOpen()
54-
55- // By default, all nodes are independent. Set this to false if you want to display groups when all subnodes are selected.
56- ->showGroupsWhenAllSelected(false)
57-
58- // By default, the clearable icon is enabled, but you can hide it with:
59- ->clearable(false)
60-
61- // Enable the option to save multiple values as a string (comma-separated)
62- ->multiple()
63-
64- // Activates the search functionality for the SelectTree.
65- ->searchable()
66-
67- // The tree is disabled. (You can also use: ->disabledOn(''))
68- ->disabled(),
33+ ```
34+
35+ ``` PHP
36+ // The label 'Category' is assigned to the field.
37+ ->label(__('Category'))
38+ ```
39+
40+ ``` PHP
41+ // Set a custom placeholder for when no items are selected
42+ ->placeholder(__('Your custom placeholder here'))
43+ ```
44+
45+ ``` PHP
46+ // Ensures that only leaf nodes can be selected while preventing the selection of groups.
47+ ->disabledBranchNode()
48+ ```
49+
50+ ``` PHP
51+ // Show the count of children alongside the group's name.
52+ ->withCount()
53+ ```
54+
55+ ``` PHP
56+ // To disable tags and display a text message instead (e.g., "X items have been selected")
57+ // Tags is always disabled on single select
58+ ->disableTags()
59+ ```
60+
61+ ``` PHP
62+ // To keep the dropdown open at all times
63+ ->alwaysOpen()
64+ ```
65+
66+ ``` PHP
67+ // By default, all nodes are independent.
68+ ->independent(false)
69+ ```
70+
71+ ``` php
72+ // By default, the clearable icon is enabled, but you can hide it with:
73+ ->clearable(false)
74+ ```
75+
76+ ``` php
77+ // Enable the option to save multiple values as a string (comma-separated)
78+ ->multiple()
79+ ```
80+
81+ ``` PHP
82+ // Activates the search functionality for the SelectTree.
83+ ->searchable()
84+ ```
85+
86+ ``` PHP
87+ // The tree is disabled. (You can also use: ->disabledOn(''))
88+ ->disabled(),
6989```
7090
7191## Changelog
0 commit comments