How to add confirmation field to front end user profile form
Created 7 years ago by mattcdavis1

What is the proper way to add a password confirmation field to front end user profile form (for the password field). If i just add the extra field and rule via UserFormFields it doesn't work since there is not actually a password_confirmation streams field. I don't want to create a streams field either since this information shouldn't be saved. I suppose on option would be to create a custom "Confirmation" field type that just never saves any data but wasn't sure if there was a better way to do this.

mattcdavis1  —  7 years ago

Below is how i ended up handling this (in the FormBuilder class):

 public function saveForm()
{
    $request = request();

    // don't save form if confirmation doesn't match
    if ($request->input('password') != $request->input('password_confirmation')) {
        $form = $this->getForm();
        $errors = new MessageBag([
            'password_confirmation' => 'The "Password" confirmation does not match.',
        ]);

        $form->setErrors($form->getErrors()->merge($errors));

        return;
    }

    parent::saveForm();
}