public function getFields()
 {
     $fields = ['password_current' => ['class' => PasswordField::className(), 'label' => UserModule::t('Current password'), 'hint' => UserModule::t('Enter your current password to confirm')], 'password_create' => ['class' => PasswordField::className(), 'validators' => [new MinLengthValidator(6)], 'label' => UserModule::t('Password')], 'password_repeat' => ['class' => PasswordField::className(), 'validators' => [new MinLengthValidator(6)], 'label' => UserModule::t('Password repeat'), 'hint' => UserModule::t('Please repeat your password')]];
     if (empty($this->getModel()->password)) {
         unset($fields['password_current']);
     }
     return $fields;
 }
Esempio n. 2
0
 public function getFields()
 {
     $fields = ['username' => ['class' => CharField::className(), 'label' => UserModule::t('Username'), 'required' => true, 'validators' => [function ($value) {
         if (User::objects()->filter(['username' => $value])->count() > 0) {
             return UserModule::t("Username must be a unique");
         }
         return true;
     }]], 'email' => ['class' => EmailField::className(), 'label' => UserModule::t('Email'), 'required' => true, 'validators' => [function ($value) {
         if (User::objects()->filter(['email' => $value])->count() > 0) {
             return UserModule::t("Email must be a unique");
         }
         return true;
     }]], 'password' => ['class' => PasswordField::className(), 'validators' => [new MinLengthValidator(6)], 'label' => UserModule::t('Password')], 'password_repeat' => ['class' => PasswordField::className(), 'validators' => [new MinLengthValidator(6)], 'label' => UserModule::t('Password repeat')]];
     $module = Mindy::app()->getModule('User');
     if ($module->enableRecaptcha) {
         if (empty($module->recaptchaPublicKey) && empty($module->recaptchaSecretKey)) {
             Mindy::app()->logger->warning("publicKey and secretKey isn't set in UserModule");
         } else {
             $fields['captcha'] = ['class' => RecaptchaField::className(), 'label' => Translate::getInstance()->t('validation', 'Captcha'), 'publicKey' => $module->recaptchaPublicKey, 'secretKey' => $module->recaptchaSecretKey];
         }
     }
     return $fields;
 }
 public function getFormField($form, $fieldClass = null, array $extra = [])
 {
     return parent::getFormField($form, \Mindy\Form\Fields\PasswordField::className(), $extra);
 }
Esempio n. 4
0
 public function getFields()
 {
     return ['username' => ['class' => CharField::className(), 'label' => UserModule::t('Email or username'), 'html' => ['placeholder' => UserModule::t('Email or username')]], 'password' => ['class' => PasswordField::className(), 'label' => UserModule::t('Password'), 'html' => ['placeholder' => UserModule::t('Password')]], 'rememberMe' => ['class' => CheckboxField::className(), 'label' => UserModule::t('Remember me'), 'value' => true]];
 }