I can not update the user password via sonataadmin dashboard.
I use symfony2 FosUserBundle2.0 SonataAdminBundle(but not use SonataUserBundle) and follow the Document to do.
MyUserBundle\Admin\UserAdmin.php class UserAdmin extends Admin like this
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
......
->add('plainPassword', 'repeated', array(
'type' => 'password',
'options' => array('translation_domain' => 'FOSUserBundle'),
'first_options' => array('label' => 'form.password'),
'second_options' => array('label' => 'form.password_confirmation'),
'invalid_message' => 'fos_user.password.mismatch',
'required' => false,
)
)
..
}
there is no problem when i use sonataadminbundle dashboard to create a new user, but when i use dashboard to update the password,the password in DB doesn't change.
the others can update but the password, i don't know why. there is no any errror message.
I am new in symfony2, some one help me?
thanks to kwozny ,now i fix it~ i don't change the function configureFormFields code, just follow kwozny's advise , add the following code.i don't know why ,but i works! i can update the password and when i update the others(password field is empty) the password will not change.
public function prePersist($object)
{
parent::prePersist($object);
}
public function preUpdate($object)
{
parent::preUpdate($object);
}