public function createComponentForm() { $form = $this->formFactory->create($this->user); $form->addPassword('old_password', 'Old password')->addRule(function ($input) { return $this->user->validatePassword($input->value); }, 'Password does not match with your password'); $form->addPassword('password', 'New password')->setRequired()->addRule($form::MIN_LENGTH, 'Minimum length of the password is %d characters', 6); $form->addPassword('password_repeat', 'Repeat password')->setRequired()->addRule($form::EQUAL, 'Passwords do not match', $form['password']); $form->addSubmit('ok', 'Change'); $form->onAfterSuccess[] = function () { $this->onChange($this, $this->user); }; return $form; }
/** * @return Form */ public function createComponentForm() { $form = $this->formFactory->create($this->user); if ($this->namespace->isNamed()) { $form->addText('username', 'Username'); } $form->addText('email', 'E-mail'); if ($this->allowPasswordEdit) { $form->addPassword('password', 'Password'); } $form->addSubmit('ok', 'Save'); $form->onAfterSuccess[] = function () { $this->onSave($this, $this->user); }; return $form; }