You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -325,14 +326,16 @@ The `getActions()` method defines actions that are displayed next to the page's
325
326
The `getTreeActions()` method defines the actions that are displayed for each record in the tree. For example:
326
327
327
328
```php
328
-
use Filament\Pages\Actions\Action;
329
+
use SolutionForest\FilamentTree\Actions\DeleteAction;
330
+
use SolutionForest\FilamentTree\Actions\EditAction;
331
+
use SolutionForest\FilamentTree\Actions\ViewAction;
329
332
330
333
protected function getTreeActions(): array
331
334
{
332
335
return [
333
-
Actions\ViewAction::make(),
334
-
Actions\EditAction::make(),
335
-
Actions\DeleteAction::make(),
336
+
ViewAction::make(),
337
+
EditAction::make(),
338
+
DeleteAction::make(),
336
339
];
337
340
}
338
341
@@ -408,6 +411,139 @@ public function getTreeRecordTitle(?\Illuminate\Database\Eloquent\Model $record
408
411
}
409
412
```
410
413
414
+
#### Configuring Tree Item Actions
415
+
416
+
You can customize the behavior and appearance of tree item actions (Delete, Edit, and View) by overriding the configuration methods in your widget or page class. Each action type has its own configuration method:
417
+
418
+
##### Configure Delete Action
419
+
420
+
Override the `configureDeleteAction()` method to customize the delete action:
421
+
422
+
```php
423
+
protected function configureDeleteAction(DeleteAction $action): DeleteAction
424
+
{
425
+
$action
426
+
->label('Remove Item')
427
+
->icon('heroicon-o-trash')
428
+
->color('danger')
429
+
->requiresConfirmation()
430
+
->modalHeading('Delete Category')
431
+
->modalDescription('Are you sure you want to delete this category? This action cannot be undone.')
432
+
->modalSubmitActionLabel('Yes, delete it');
433
+
434
+
return $action;
435
+
}
436
+
```
437
+
438
+
##### Configure Edit Action
439
+
440
+
Override the `configureEditAction()` method to customize the edit action:
441
+
442
+
```php
443
+
protected function configureEditAction(EditAction $action): EditAction
444
+
{
445
+
$action
446
+
->label('Edit Item')
447
+
->icon('heroicon-o-pencil')
448
+
->color('primary')
449
+
->modalHeading('Edit Category')
450
+
->modalSubmitActionLabel('Save Changes')
451
+
->slideOver();
452
+
453
+
return $action;
454
+
}
455
+
```
456
+
457
+
##### Configure View Action
458
+
459
+
Override the `configureViewAction()` method to customize the view action:
460
+
461
+
```php
462
+
protected function configureViewAction(ViewAction $action): ViewAction
463
+
{
464
+
$action
465
+
->label('View Details')
466
+
->icon('heroicon-o-eye')
467
+
->color('secondary')
468
+
->modalHeading('Category Details')
469
+
->modalWidth('2xl')
470
+
->slideOver();
471
+
472
+
return $action;
473
+
}
474
+
```
475
+
476
+
##### Example: Complete Action Configuration
477
+
478
+
Here's a complete example showing how to configure all three actions in a tree widget:
479
+
480
+
```php
481
+
<?php
482
+
483
+
namespace App\Filament\Widgets;
484
+
485
+
use App\Models\ProductCategory;
486
+
use Filament\Forms\Components\TextInput;
487
+
use SolutionForest\FilamentTree\Actions\DeleteAction;
488
+
use SolutionForest\FilamentTree\Actions\EditAction;
489
+
use SolutionForest\FilamentTree\Actions\ViewAction;
490
+
use SolutionForest\FilamentTree\Widgets\Tree as BaseWidget;
This plugin enables you to create tree pages in the admin panel. To create a tree page for a model, use the `make:filament-tree-page` command. For example, to create a tree page for the ProductCategory model, you can run:
0 commit comments