Patrick | Der Echte!
Patrick | Der Echte!
FFilament
Created by Patrick | Der Echte! on 11/24/2024 in #❓┊help
Orchestral / Laravel Dusk: "Undefined variable $content" on login
Hello there, I am currently working on a package for Filament PHP, and I want to implement tests using Laravel Dusk. However, I’m running into issues when trying to make Filament PHP work with Orchestral / Laravel Dusk. Whenever I try to load /admin/login in a Laravel Dusk test, I receive the error Undefined variable $content in the file vendor/filament/forms/resources/views/components/checkbox.blade.php. However, when I access the same route via the Orchestral Workbench serve command (vendor/bin/testbench serve), everything works as expected. Feature tests are also working without any issues. Dan Harrin suggested ensuring that the RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider is loaded in the environment, which in my case would be Laravel Dusk. To confirm this, I’ve checked the output of App::providerIsLoaded(...) and App::getLoadedProviders() to ensure that the provider is indeed being loaded, along with the same providers as those loaded by the serve command. Despite this, the issue persists. Any ideas on what I might be missing? Thank You!
4 replies
FFilament
Created by Patrick | Der Echte! on 8/17/2024 in #❓┊help
afterStateUpdated $old does not work after using Builder/Block
Hey, i am currently trying to use afterStateUpdatedon a TextInput in combination with a Builder. The resource i am working on does have a *title *and a *slug *attribute that i have implemented as described in the documentation as well as a Builder. My issue is that after i have used any field inside a Block, the the $old parameter of the afterStateUpdated callback does equal the new value and not the old value. However, if i use any other field outside of the Builder, like test, before i change the title, it does work again. I am using the following code:
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('test'),
Forms\Components\TextInput::make('title')
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(function (Forms\Get $get, Forms\Set $set, ?string $old, ?string $state) {
if (($get('slug') ?? '') !== Str::slug($old)) {
return;
}

$set('slug', Str::slug($state));
}),
Forms\Components\TextInput::make('slug')
->required()
->maxLength(255),

Forms\Components\Builder::make('data')
->blocks([
Builder\Block::make('heading')
->schema([
Components\TextInput::make('content')
->label('Heading')
->required(),
Components\Select::make('level')
->options([
'h1' => 'Heading 1',
'h2' => 'Heading 2',
'h3' => 'Heading 3',
'h4' => 'Heading 4',
'h5' => 'Heading 5',
'h6' => 'Heading 6',
])
->required()
])
->columns(2);
])
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('test'),
Forms\Components\TextInput::make('title')
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(function (Forms\Get $get, Forms\Set $set, ?string $old, ?string $state) {
if (($get('slug') ?? '') !== Str::slug($old)) {
return;
}

$set('slug', Str::slug($state));
}),
Forms\Components\TextInput::make('slug')
->required()
->maxLength(255),

Forms\Components\Builder::make('data')
->blocks([
Builder\Block::make('heading')
->schema([
Components\TextInput::make('content')
->label('Heading')
->required(),
Components\Select::make('level')
->options([
'h1' => 'Heading 1',
'h2' => 'Heading 2',
'h3' => 'Heading 3',
'h4' => 'Heading 4',
'h5' => 'Heading 5',
'h6' => 'Heading 6',
])
->required()
])
->columns(2);
])
]);
}
Any idea what could be wrong?
4 replies