Checkbox::make('password_change_checkbox')
->label('Change your password')
->visibleOn('edit')
->live(),
TextInput::make('password')
->dehydrated(fn(Get $get): bool => $get('password') != '')
->live()
->afterStateUpdated(
function (
Forms\Contracts\HasForms $livewire,
Forms\Components\TextInput $component
) {
$livewire->validateOnly($component->getStatePath());
})
->confirmed()
->required()
->label('Password')
->visibleOn('edit')
->hidden(fn(Get $get): bool => !$get('password_change_checkbox')),
TextInput::make('password_confirmation')
->dehydrated(false)
->live()
->afterStateUpdated(
function (
Forms\Contracts\HasForms $livewire,
Forms\Components\TextInput $component
) {
$livewire->validateOnly($component->getStatePath());
})
->required()
->label('Repeat password')
->visibleOn('edit')
->hidden(fn(Get $get): bool => !$get('password_change_checkbox'))
Checkbox::make('password_change_checkbox')
->label('Change your password')
->visibleOn('edit')
->live(),
TextInput::make('password')
->dehydrated(fn(Get $get): bool => $get('password') != '')
->live()
->afterStateUpdated(
function (
Forms\Contracts\HasForms $livewire,
Forms\Components\TextInput $component
) {
$livewire->validateOnly($component->getStatePath());
})
->confirmed()
->required()
->label('Password')
->visibleOn('edit')
->hidden(fn(Get $get): bool => !$get('password_change_checkbox')),
TextInput::make('password_confirmation')
->dehydrated(false)
->live()
->afterStateUpdated(
function (
Forms\Contracts\HasForms $livewire,
Forms\Components\TextInput $component
) {
$livewire->validateOnly($component->getStatePath());
})
->required()
->label('Repeat password')
->visibleOn('edit')
->hidden(fn(Get $get): bool => !$get('password_change_checkbox'))