Edit action does not work: method sholdOpenModal does not exists
Hi, I got such error.
When click on edit button on tree element I got error as on screen.
I fixed it by extend SolutionForest\FilamentTree\Actions\EditAction and SolutionForest\FilamentTree\Actions\DeleteAction classes and put fake method shouldOpenModal to each of them:
<?php
namespace App\Filament\Resources\SupplierProductCategoryResource\Pages;
use App\Filament\Resources\SupplierProductCategoryResource;
use Filament\Pages\Actions\CreateAction;
use SolutionForest\FilamentTree\Actions;
use SolutionForest\FilamentTree\Actions\EditAction as BaseEditAction;
use SolutionForest\FilamentTree\Actions\DeleteAction as BaseDeleteAction;
use SolutionForest\FilamentTree\Concern;
use SolutionForest\FilamentTree\Resources\Pages\TreePage as BasePage;
use SolutionForest\FilamentTree\Support\Utils;
use Filament\Actions as FilamentActions;
class EditAction extends BaseEditAction
{
public function shouldOpenModal($checkForFormUsing)
{
return true;
}
}
class DeleteAction extends BaseDeleteAction
{
public function shouldOpenModal($checkForFormUsing)
{
return true;
}
}
class SupplierProductCategoryTree extends BasePage
{
protected static string $resource = SupplierProductCategoryResource::class;
protected static int $maxDepth = 3;
protected function getActions(): array
{
return [
$this->getCreateAction(),
];
}
protected function getTreeActions(): array
{
return [
EditAction::make(),
DeleteAction::make()
];
}
protected function hasDeleteAction(): bool
{
return false;
}
protected function hasEditAction(): bool
{
return false;
}
protected function hasViewAction(): bool
{
return false;
}
protected function getHeaderWidgets(): array
{
return [];
}
protected function getFooterWidgets(): array
{
return [];
}
// CUSTOMIZE ICON OF EACH RECORD, CAN DELETE
// public function getTreeRecordIcon(?\Illuminate\Database\Eloquent\Model $record = null): ?string
// {
// return null;
// }
}
I am also getting exactly same error and also tried above changes which didn't worked for me.
kuzovkov Thanks for the solution it works
In version 2.1.0, we have added back this logics. Please upgrade to the latest version and check if the issue you were experiencing still occurs.