Filamentphp - hide form component berdasarkan operation

Hiding components based on the current operation

 use Livewire\Component;  
 Forms\Components\TextInput::make('password')  
   ->password()  
   ->required()  
   ->hiddenOn('edit'),  

Injecting the current form operation

<?php

// https://filamentphp.com/docs/3.x/panels/resources/getting-started#hiding-components-based-on-the-current-operation
 
function (string $operation) {  
   // ...  
 }  

 
<?php

// https://filamentphp.com/docs/3.x/panels/resources/editing-records#saving-a-part-of-the-form-independently 

use Filament\Forms\Components\Actions\Action;  
 use Filament\Forms\Components\Section;  
 use Filament\Notifications\Notification;  
 use Filament\Resources\Pages\EditRecord;  
 Section::make('Rate limiting')  
   ->schema([  
     // ...  
   ])  
   ->footerActions([  
     fn (string $operation): Action => Action::make('save')  
       ->action(function (Section $component, EditRecord $livewire) {  
         $livewire->saveFormComponentOnly($component);  
         Notification::make()  
           ->title('Rate limiting saved')  
           ->body('The rate limiting settings have been saved successfully.')  
           ->success()  
           ->send();  
       })  
       ->visible($operation === 'edit'),  
   ])  

Post a Comment

Previous Post Next Post