Jump to:

23478 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » how to use ConfirmedPasswordField

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 477 Views
  • Optic Blaze
    Community Member
    162 Posts

    how to use ConfirmedPasswordField Link to this post

    Hi there,

    I am trying to use ConfirmedPasswordField in a registration page. I have managed to get it to work, but now i want to impose some additional validation on the object eg set the min number of charachters to 8, enforce both numbers and letters be used etc.

    I am trying to use it as follows, but it does not work:

    class RegisterPage_Controller extends Page_Controller {

    function Form() {
    $member = new Member();
    $fields = $member->getMemberFormFields();

    $actions = new FieldSet(
             new FormAction('register', 'Register')

          $password = new ConfirmedPasswordField ('Password', 'Password'); // this works
          $password->setCanBeEmpty('false'); //this works
    $password->setMinLenth('8'); // gives errors
    $password->setMaxLenth('16'); // gives errors
    $password->characterStrength(2, array('lowercase', 'uppercase', 'digits', 'punctuation'));

       $fields->insertAfter($password, "Email");
    $validator = new RequiredFields('FirstName','Surname','Email','Password');   

    $form = new Form($this, 'Form', $fields, $actions, $validator);

          return $form;

    Please help, Thanx

  • swaiba
    Forum Moderator
    1792 Posts
  • Optic Blaze
    Community Member
    162 Posts

    Re: how to use ConfirmedPasswordField Link to this post

    Ok thanks, i had tried those tutorials, but when i tested the validator it seemed asif it was not working. The problem was that error reporting was not on.

    Now i see the following error:

    "[User Error] Uncaught ValidationException: Validation error writing a Member object: Password is too short, it must be 7 or more characters long.; You need to increase the strength of your passwords by adding some of the following characters: uppercase, digits, punctuation. Object not written."

    Ok so it is working, but it is throwing out an exception that might freak a normal user out.

    How do i get it to to display an error message on the page..i.e a template that explains the error to the user as apposed to an exception that looks like the webiste is not working?


    Attached Files
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.