From d7d53c0e8bbd15f123147b879378c5ee89070588 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Thu, 9 Apr 2026 13:14:01 +0700 Subject: [PATCH] feat: add labels to form fields and configure global validation attribute mapping to field labels --- app/Filament/Pages/Company/Schemas/CompanyForm.php | 4 ++++ app/Filament/Pages/Media/Schemas/MediaForm.php | 2 ++ app/Providers/AppServiceProvider.php | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/app/Filament/Pages/Company/Schemas/CompanyForm.php b/app/Filament/Pages/Company/Schemas/CompanyForm.php index 1e06729..9ae0122 100644 --- a/app/Filament/Pages/Company/Schemas/CompanyForm.php +++ b/app/Filament/Pages/Company/Schemas/CompanyForm.php @@ -69,6 +69,7 @@ public static function configure(Schema $schema): Schema Section::make('NIk Direktur') ->schema([ TextInput::make('director_nik') + ->label('NIK Direktur') ->hiddenLabel() ->placeholder('32***') ->autocomplete(false) @@ -79,6 +80,7 @@ public static function configure(Schema $schema): Schema ->regex('/^[0-9]+$/'), AdvancedFileUpload::make('director_nik_docs') + ->label('Dokumen NIK Direktur') ->hiddenLabel() ->disk(config('filesystems.default')) ->acceptedFileTypes(['image/*']) @@ -94,6 +96,7 @@ public static function configure(Schema $schema): Schema return Section::make(fn () => $doc['title']) ->schema([ TextInput::make($doc['text_name']) + ->label($doc['title']) ->hiddenLabel() ->placeholder($doc['placeholder']) ->autocomplete(false) @@ -101,6 +104,7 @@ public static function configure(Schema $schema): Schema ->maxLength($doc['max']), AdvancedFileUpload::make($doc['file_name']) + ->label('Dokumen '.$doc['title']) ->hiddenLabel() ->disk(config('filesystems.default')) ->acceptedFileTypes($doc['accept']) diff --git a/app/Filament/Pages/Media/Schemas/MediaForm.php b/app/Filament/Pages/Media/Schemas/MediaForm.php index 62228f0..9f16062 100644 --- a/app/Filament/Pages/Media/Schemas/MediaForm.php +++ b/app/Filament/Pages/Media/Schemas/MediaForm.php @@ -73,6 +73,7 @@ public static function configure(Schema $schema): Schema return Section::make(fn () => $doc['title']) ->schema([ TextInput::make($doc['text_name']) + ->label($doc['title']) ->hiddenLabel() ->placeholder($doc['placeholder']) ->autocomplete(false) @@ -80,6 +81,7 @@ public static function configure(Schema $schema): Schema ->maxLength($doc['max']), AdvancedFileUpload::make($doc['file_name']) + ->label('Dokumen '.$doc['title']) ->hiddenLabel() ->disk(config('filesystems.default')) ->acceptedFileTypes($doc['accept']) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index bd25ee9..a860ad1 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use Filament\Forms\Components\Field; use Illuminate\Http\Request; use Illuminate\Support\Facades\URL; use Illuminate\Support\ServiceProvider; @@ -59,5 +60,9 @@ public function boot(): void if (! app()->environment('local')) { URL::forceScheme('https'); } + + Field::configureUsing(function (Field $field): void { + $field->validationAttribute(fn (Field $component) => $component->getLabel()); + }); } }