addUserEmailElement(); $this->addElement('password', 'password', [ 'label' => 'Password', 'required' => true, 'autocomplete' => 'off', 'maxlength' => 255, ]); $this->getElement('password')->addValidator('Password', true); $this->getElement('password')->addValidator('Callback', true, [[$this, 'validatePassword']]); $this->addElement('password', 'confirmPassword', [ 'label' => 'Confirm Password', 'required' => true, 'autocomplete' => 'off', 'maxlength' => 255, ]); $this->getElement('confirmPassword')->addValidator('ConfirmPassword', true, ['password']); $this->addElement('text', 'firstName', ['label' => 'First Name', 'required' => true, 'maxlength' => 255]); $this->addElement('text', 'lastName', ['label' => 'Last Name', 'required' => true, 'maxlength' => 255]); $this->addElement('phone', 'directPhone', ['label' => 'Phone Number', 'required' => true]); $this->addElement('captcha', 'captcha', ['label' => 'Enter image code']); return $this; } public function validatePassword($value, $context = null) { if (!empty($value) && empty($context['confirmPassword'])) { $this->getElement('confirmPassword')->setRequired()->isValid(''); $this->getElement('confirmPassword')->setErrors(['Password confirmation does not match']); } return true; } public function addButtons() { parent::addStepButtons(['previous' => false]); return $this; } }