From 96000ce97e45e6615e9373b5f425cdcbae661d35 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Wed, 19 May 2021 09:11:06 -0400 Subject: [PATCH] switch from deprecated function --- CRM/Contact/Form/Task/Useradd.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/CRM/Contact/Form/Task/Useradd.php b/CRM/Contact/Form/Task/Useradd.php index cb78c3c38a..4aa24ce2ad 100644 --- a/CRM/Contact/Form/Task/Useradd.php +++ b/CRM/Contact/Form/Task/Useradd.php @@ -77,10 +77,7 @@ class CRM_Contact_Form_Task_Useradd extends CRM_Core_Form { $this->add('password', 'cms_pass', ts('Password'), ['class' => 'huge']); $this->add('password', 'cms_confirm_pass', ts('Confirm Password'), ['class' => 'huge']); $this->addRule('cms_pass', ts('Password is required'), 'required'); - $this->addRule([ - 'cms_pass', - 'cms_confirm_pass', - ], ts('Password mismatch'), 'compare'); + $this->addFormRule(['CRM_Contact_Form_Task_Useradd', 'passwordMatch']); } $this->add('text', 'email', ts('Email'), ['class' => 'huge'])->freeze(); @@ -140,4 +137,18 @@ class CRM_Contact_Form_Task_Useradd extends CRM_Core_Form { return empty($errors) ? TRUE : $errors; } + /** + * Validation Rule. + * + * @param array $params + * + * @return array|bool + */ + public static function passwordMatch($params) { + if ($params['cms_pass'] !== $params['cms_confirm_pass']) { + return ['cms_pass' => ts('Password mismatch')]; + } + return TRUE; + } + } -- 2.25.1