DEV Community

JohnDivam
JohnDivam

Posted on

6 1

Filament: add a confirmation password field in a form

To add a confirmation password field in a form, you typically want to ensure that the user correctly enters their password twice to prevent typos and ensure accuracy .

Forms\Components\TextInput::make('password')
                    ->password()
                    ->required()
                    ->maxLength(255),
 Forms\Components\TextInput::make('password_confirmation')
                    ->password()
                    ->required()
                    ->maxLength(255)
                    ->same('password')
                    ->label('Confirm Password'),
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
khaledelansari profile image
Khaled Al-Ansari

If you don't want to add password_confirmation when you save the data you can to it ->dehydrated(false) which will remove when getData is called on saving.

Anyway, nice tip John.

Collapse
 
atmorojo profile image
Risyad Rais Rafsanjani

This is a great help. Thank you so much!

Collapse
 
almanza023 profile image
Eduardo Antonio Almanza Pérez

Excelente

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay