I have a Profile
form that inherits from sfGuardRegisterForm
I have these fields:
$this->useFields(
array('first_name',
'last_name',
'email_address',
'country',
'language',
'current_password',
'new_password',
'password_again',
)
);
Required fields are:
email_address
, country
and language
And the conditions are:
- If the
email_address
is not equal with the currentemail_address
then check if it's unique then save it - If the
current_password
is the actual password of the user then verify ifnew_password
andpassword_again
are equals and verify that thenew_password
is not equal to the actual password of the user
I just can't figure out in how implement this
EDIT
Thanks 1ed your example works but the problem is that I load the user Profile and I fill the fields: 'first_name', 'last_name', 'email_address', 'country', 'language'
with the actual logged user so the email_address
field will show the email address:
//...
$this->widgetSchema['email_address']->setDefault($this->_user->getEmailAddress());
//...
If the user dont change the email it will always show this message:
An object with the same "email_address" already exist.
I just want to skip that
Also this $this->getObject()->checkPassword()
does not works, always show this message:
Incorrect current password.
I use:
$this->_user = sfContext::getInstance()->getUser()->getGuardUser();
To get actual user profile
EDIT2
Thanks again 1ed
This is very weird and I'm getting frustated, this is the situation
- I have a "workaround" for this but it does not follow the standard, I can make it works but using
sfContext::getInstance()->getUser()->getGuardUser();
and it will be more unnecesary code - If I use
new ProfileForm($user)
automatically fills all the fields, that's very good but I can'tsetDefault()
I can't setnull
orempty
any field so I can't usedoUpdateObject()
because this function only works when the current data is updated, also I have tested overridingbind()
,save()
etc. without results