Created
October 28, 2023 23:19
-
-
Save atmonshi/1f9e2dc7e78a57423a0144979a3f9ba2 to your computer and use it in GitHub Desktop.
reactive Wizard filament
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Filament\Pages; | |
use Filament\Forms\Components\Select; | |
use Filament\Forms\Components\TextInput; | |
use Filament\Forms\Form; | |
use Filament\Forms\Get; | |
use Filament\Pages\Page; | |
use Filament\Forms\Components\Wizard as WizardField; | |
class Wizard extends Page | |
{ | |
public ?array $data = []; | |
protected static ?string $navigationIcon = 'heroicon-o-document-text'; | |
protected static string $view = 'filament.pages.wizard'; | |
public function mount(): void | |
{ | |
$this->form->fill(); | |
} | |
public function form(Form $form): Form | |
{ | |
return $form->schema([ | |
WizardField::make([ | |
WizardField\Step::make('Lang') | |
->id('lang-step') | |
->live() | |
->schema([ | |
Select::make('lang') | |
->live() | |
->options([ | |
'en' => 'en', | |
'es' => 'es', | |
]) | |
]), | |
WizardField\Step::make('details En') | |
->id('lang-en') | |
->live() | |
->visible(function (Get $get) { | |
return $get('lang') === 'en'; | |
}) | |
->schema([ | |
TextInput::make('nameEn') | |
]), | |
WizardField\Step::make('details Es') | |
->id('lang-es') | |
->live() | |
->visible(function (Get $get) { | |
return $get('lang') === 'es'; | |
}) | |
->schema([ | |
TextInput::make('nameEs') | |
]), | |
]) | |
// ->skippable() | |
->live() | |
->statePath('data') | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment