F
Filament4mo ago
Ashk

Alpine Expression Error: table is not defined

Hello, I have a ManageParties page, when I implement $defaultAction, or force an action in query param with ?action=create, the action doesn't open and I get errors in the browser console. Thank you for your help 🙏
Alpine Expression Error: table is not defined

Expression: "table"
Alpine Expression Error: table is not defined

Expression: "table"
No description
Solution:
FYI: I found my issue, it's related to the plugin Global Search Modal I can reproduce/fix the behaviour by add/removing the plugin in my panel provider...
Jump to solution
11 Replies
LeandroFerreira
LeandroFerreira4mo ago
Is it a custom page? Did you follow this section?
Ashk
AshkOP4mo ago
No, it's a resource page, ManageParties , I follow this section Especially "Alternatively, you can open an action modal when a page loads by specifying the action as a query string parameter to the page: /admin/products/edit/932510?action=onboarding"
Ashk
AshkOP4mo ago
The error only happen when I'm using the query param action or $defaultAction defined in the page What I tried: - composer update - clear cache + optimize
LeandroFerreira
LeandroFerreira4mo ago
php artisan filament:about what is the output? what about /admin/products?action=create ?
Dennis Koch
Dennis Koch4mo ago
Can you share the page code?
Ashk
AshkOP4mo ago
I tried http://localhost/organizations/acme-corp/parties?action=create and using $defaultAction, both lead to the same issue
No description
Ashk
AshkOP4mo ago
<?php

declare(strict_types=1);

namespace App\Filament\Tenant\Resources\PartyResource\Pages;

use App\Filament\Tenant\Resources\PartyResource;
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;
use Filament\Support\Enums\MaxWidth;

class ManageParties extends ManageRecords
{
protected static string $resource = PartyResource::class;

public $defaultAction = 'create';

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make()
->icon('heroicon-o-plus')
->modalWidth(MaxWidth::ThreeExtraLarge),
];
}
}
<?php

declare(strict_types=1);

namespace App\Filament\Tenant\Resources\PartyResource\Pages;

use App\Filament\Tenant\Resources\PartyResource;
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;
use Filament\Support\Enums\MaxWidth;

class ManageParties extends ManageRecords
{
protected static string $resource = PartyResource::class;

public $defaultAction = 'create';

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make()
->icon('heroicon-o-plus')
->modalWidth(MaxWidth::ThreeExtraLarge),
];
}
}
And the resource
<?php

declare(strict_types=1);

namespace App\Filament\Tenant\Resources;

use App\Filament\Tenant\Resources\PartyResource\Pages;
use App\Models\Party;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables\Table;

class PartyResource extends Resource
{
protected static ?string $model = Party::class;

protected static ?string $navigationIcon = 'heroicon-o-trophy';

protected static ?string $recordTitleAttribute = 'name';

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make()
->columnSpanFull()
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('size')
->nullable()
->default(4)
->minValue(0)
->maxValue(100)
->integer(),
Forms\Components\RichEditor::make('description'),
]),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([])
->filters([])
->contentGrid([])
->actions([])
->bulkActions([]);
}

public static function getPages(): array
{
return [
'index' => Pages\ManageParties::route('/'),
];
}
}
<?php

declare(strict_types=1);

namespace App\Filament\Tenant\Resources;

use App\Filament\Tenant\Resources\PartyResource\Pages;
use App\Models\Party;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables\Table;

class PartyResource extends Resource
{
protected static ?string $model = Party::class;

protected static ?string $navigationIcon = 'heroicon-o-trophy';

protected static ?string $recordTitleAttribute = 'name';

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make()
->columnSpanFull()
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('size')
->nullable()
->default(4)
->minValue(0)
->maxValue(100)
->integer(),
Forms\Components\RichEditor::make('description'),
]),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([])
->filters([])
->contentGrid([])
->actions([])
->bulkActions([]);
}

public static function getPages(): array
{
return [
'index' => Pages\ManageParties::route('/'),
];
}
}
I simplify both file, but with this code, for both files, I've the same exact issue
LeandroFerreira
LeandroFerreira4mo ago
looks good to me. Are you able to create a minimal repo on github to reproduce this issue?
Ashk
AshkOP4mo ago
Ok the issue is probably related to my local infra setup (using laravel sail) I don't reproduce using Coolify + Nixpack I thought it was related to a code issue, but not at all, the same code work well in my staging, I need to investigate more Thank you a lot for your help, I'll share my solution if I find something 🙏
Solution
Ashk
Ashk4mo ago
FYI: I found my issue, it's related to the plugin Global Search Modal I can reproduce/fix the behaviour by add/removing the plugin in my panel provider
Ashk
AshkOP4mo ago
Issue open on plugin repository, thank you again for your help https://github.com/CharrafiMed/global-search-modal/issues/98
GitHub
Query param action on panel page · Issue #98 · CharrafiMed/global...
Hello, I&#39;m not able to explain the issue, but it&#39;s easy to reproduce. clone the filament demo install the package set the plugin in the provider try to use the query param action like http:...

Did you find this page helpful?