Replies: 1 comment
-
|
I found that the solution is this: <?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
\Filament\Forms\Components\Field::configureUsing(
function (\Filament\Forms\Components\Field $component) {
$component->label(
fn($component) => Str::title(str_replace('_', ' ', $component->getName()))
);
$component->validationAttribute(
fn($component) => Str::lower($component->getLabel())
);
}
);
\Filament\Tables\Columns\Column::configureUsing(
function (\Filament\Tables\Columns\Column $column) {
$column->label(
fn($column) => Str::title(str_replace('_', ' ', $column->getName()))
);
if (method_exists($column, 'validationAttribute')) {
$column->validationAttribute(
fn($column) => Str::lower($column->getLabel())
);
}
}
);
\Filament\Actions\Imports\ImportColumn::configureUsing(
function (\Filament\Actions\Imports\ImportColumn $component) {
$component->label(
fn($component) => Str::title(str_replace('_', ' ', $component->getName()))
);
$component->validationAttribute(
fn($component) => Str::lower($component->getLabel())
);
}
);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The default code for validation attribute is using
Str::lcfirst($this->getLabel())which is repeated on the following places:vendor\filament\actions\src\Imports\ImportColumn.phpgetValidationAttribute()vendor\filament\forms\src\Components\Concerns\CanBeValidated.phpgetValidationAttribute()vendor\filament\tables\src\Columns\Concerns\CanBeValidated.phpgetValidationAttribute()I would like to override this behavior for example replacing the code with:
Idea:
Probably we can add a static
$defaultValidationAttributeCallbackon those three then register those callback on service provider.if this were not registered in service provider, validation attribute will behave originally.
Beta Was this translation helpful? Give feedback.
All reactions