Jouri Jalving
Jouri Jalving
FFilament
Created by Jouri Jalving on 2/21/2025 in #❓┊help
Create a dashboard page for a resource
The documents mention creating multiple dashboard. But is it possible to have a dashboard linked to a resource, So it shows up in the tab bare like the View and Edit pages? I've tried adding a custom page, and then I can navigate there through the tabs. But I'm missing features that dashboard page have access to like the filtersForm method. And also I can't get the resource tabs to show up on the custom page.
2 replies
FFilament
Created by Jouri Jalving on 8/6/2024 in #❓┊help
Share validation rules with api resource controllers
What's the best way to reuse validation rules between my api resource controller and Filament? I've tried to re-use the validation rules from custom FormRequest:
public static function form(Form $form): Form
{
if($form->getOperation() === 'create') {
$userRequest = new StoreUserRequest();
} else {
$userRequest = new UpdateUserRequest();
}

return $form
->schema([
Forms\Components\TextInput::make('first_name')
->rules($userRequest->rules()['first_name']),
Forms\Components\TextInput::make('last_name')
->rules($userRequest->rules()['last_name']),
Forms\Components\TextInput::make('email')
->rules($userRequest->rules()['email']),
Forms\Components\TextInput::make('password')
->rules($userRequest->rules()['email'])
->dehydrateStateUsing(fn ($state) => Hash::make($state))
->dehydrated(fn ($state) => filled($state))
]);
}
public static function form(Form $form): Form
{
if($form->getOperation() === 'create') {
$userRequest = new StoreUserRequest();
} else {
$userRequest = new UpdateUserRequest();
}

return $form
->schema([
Forms\Components\TextInput::make('first_name')
->rules($userRequest->rules()['first_name']),
Forms\Components\TextInput::make('last_name')
->rules($userRequest->rules()['last_name']),
Forms\Components\TextInput::make('email')
->rules($userRequest->rules()['email']),
Forms\Components\TextInput::make('password')
->rules($userRequest->rules()['email'])
->dehydrateStateUsing(fn ($state) => Hash::make($state))
->dehydrated(fn ($state) => filled($state))
]);
}
But I can't seem to get access to the request values. I both the $this->input() and $this->request->all() are completely empty, so my custom validation rules fail.
1 replies