21491 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 233 Views |
-
how to use ConfirmedPasswordField

18 September 2012 at 9:40am
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
-
Re: how to use ConfirmedPasswordField

19 September 2012 at 1:06am
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?
Thanks
| 233 Views | ||
|
Page:
1
|
Go to Top |


