help in setting a user profile page

Notice: This thread is very old.
kc2scy
Member | 22
+
0
-

hello,

I have successfully set a presenter that gather user information like a screen name,password, profile picture etc.

I then setup a presenter that allows the user to modify there information. however I ran into a design problem with passwords and profile picture. if the user doesn't want to change their password and say just wants to change their screen name then my “FormSucceeded” event does not fire because ( I believe) the validation failed. I get around this with the email address and screen name by adding a default value from the database.

I got around this by turning off the validation, but I really would like the validation still to work. I run into the same scenario with the password.

I have the password control set this way.

$form->addPassword('password', 'Password:')
       ->setRequired('Please enter your password.');

       $form->addPassword('passwordVerfify', 'Verfify Password:')
       ->setRequired('Please enter your password again.');

How does one setup something like this?

Last edited by kc2scy (2014-02-21 02:29)

David Matějka
Moderator | 6275
+
0
-

use addCondition

$form->addPassword('password', 'Password:')
	->addCondition($form::FILLED)
	->addRule($form::MIN_LENGTH, "Password has to be at least %d chars long", 6);

$form->addPassword('passwordVerfify', 'Verfify Password:')
	->addConditionOn($form['password'], $form::FILLED)
	->addRule($form::EQUAL, 'Password missmatch', $form['password']);
Tomáš Votruba
Moderator | 1110
+
0
-

Is the addConditionOn somehow useful? I use this without.

Last edited by Tomáš Votruba (2014-02-21 09:06)

Majkl578
Moderator | 1364
+
0
-

It is, without it, it will scream that passwords do not match even when the password field is empty. That is, from user's point of view, a bit weird, if he e.g. just hasn't filled it in yet.
What makes me wonder is “addCondition” on “password”, allowing user not to have password sounds strange, maybe bug in matej21's code.

David Matějka
Moderator | 6275
+
0
-

@Majkl578: Maybe I did misunderstand the question (or you? :)) but it allows you to not change the password if you don't want to and allows you to change only eg. your username.

Tomáš Votruba
Moderator | 1110
+
0
-

@Majkl578: When both are empty they're EQUAL, so it shouldn't scream, right?

kc2scy
Member | 22
+
0
-

matej21 wrote:

use addCondition

$form->addPassword('password', 'Password:')
	->addCondition($form::FILLED)
	->addRule($form::MIN_LENGTH, "Password has to be at least %d chars long", 6);

$form->addPassword('passwordVerfify', 'Verfify Password:')
	->addConditionOn($form['password'], $form::FILLED)
	->addRule($form::EQUAL, 'Password missmatch', $form['password']);

Thanks!! when I get home tonight going to give it a try.

kc2scy
Member | 22
+
0
-

all worked now I just have the file upload to deal with thanks again.