From 00ae275f75eb3e81c719d17ec3bdde0cec758435 Mon Sep 17 00:00:00 2001 From: James Cocker Date: Tue, 22 Feb 2022 12:24:28 +0000 Subject: [PATCH 1/2] Add custom setForm() method for ConfirmedPasswordField Fixes bug that makes it impossible to set a ConfirmedPasswordField as "required" due to the two child fields not getting a form assigned. --- src/Forms/ConfirmedPasswordField.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Forms/ConfirmedPasswordField.php b/src/Forms/ConfirmedPasswordField.php index 5cd8ece1e57..8892eb47a0f 100644 --- a/src/Forms/ConfirmedPasswordField.php +++ b/src/Forms/ConfirmedPasswordField.php @@ -694,4 +694,22 @@ public function getRequireStrongPassword() { return $this->requireStrongPassword; } + + /** + * Set the container form. + * + * This is called automatically when fields are added to forms. + * + * @param Form $form + * + * @return $this + */ + public function setForm($form) + { + $this->form = $form; + $this->getPasswordField()->form = $form; + $this->getConfirmPasswordField()->form = $form; + + return $this; + } } From 51bb9254e88a8fbe7abf45a43ad731e074d450fe Mon Sep 17 00:00:00 2001 From: James Cocker Date: Tue, 22 Feb 2022 15:59:23 +0000 Subject: [PATCH 2/2] Add custom setForm() method for ConfirmedPasswordField (Tweaks) --- src/Forms/ConfirmedPasswordField.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Forms/ConfirmedPasswordField.php b/src/Forms/ConfirmedPasswordField.php index 8892eb47a0f..395bc250679 100644 --- a/src/Forms/ConfirmedPasswordField.php +++ b/src/Forms/ConfirmedPasswordField.php @@ -706,10 +706,10 @@ public function getRequireStrongPassword() */ public function setForm($form) { - $this->form = $form; - $this->getPasswordField()->form = $form; - $this->getConfirmPasswordField()->form = $form; - + $this->getPasswordField()->setForm($form); + $this->getConfirmPasswordField()->setForm($form); + + parent::setForm($form); return $this; } }