Laravel Filament 3.X create a Dynamic Form

339 Views Asked by At

I want to create Form, if the user select for the level as Customer, Then the Customer Information will be Shown, IF other level are selected then the input field for Customer Information are hidden.

return $form
            ->schema([
                
                Forms\Components\Section::make('User Credentials')
                ->description('Enter the User Credential here.')
                ->schema([
                Forms\Components\Select::make('level')
                    ->options([
                        '1' => 'Admin',
                        '2' => 'Customer',
                        '3' => 'Agent',
                    ])
                    ->required(),

                ])->columns(2),
                Forms\Components\Section::make('Customer Information')
                ->description('Enter the User Detail here.')
                ->schema([
                
                Forms\Components\TextInput::make('Contact Info')
                    ->required()
                    ->tel()
                    ->telRegex('/^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\.\/0-9]*$/')
                    ->maxLength(15),
                Forms\Components\TextInput::make('Address')
                    ->required()
                    ->columnSpanFull()
                    ->maxLength(255),
                Forms\Components\Select::make('State')
                    ->options([
                        '1' => 'Admin',
                        '2' => 'Customer',
                        '3' => 'Agent',
                    ])
                    ->required(),
                Forms\Components\TextInput::make('Postcode')
                    ->numeric()    
                    ->required()
                    ->maxLength(5),
                
                   
                ])->columns(2),
                
                Forms\Components\DateTimePicker::make('email_verified_at'),
                
                
            ]):

Need some Idea for this to work

0

There are 0 best solutions below