Czesc,
Mam problem z implementacja setPassword w tabeli sfGuardUser. To co mam to nie dziala, nie zapisuje zakodowanych wartosci do tabeli. Czy moze sa jakies potrzebne credentiale zeby taki zapis przeprowadzic? Nie wiem gdzie moze byc blad..Pomozcie
<?php
public function executeEdit(sfWebRequest $request)
{
$this->forward404Unless($sf_guard_user = sfGuardUserPeer
::retrieveByPk($this->getUser()->getGuardUser()->getId()), sprintf('Object sf_guard_user does not exist (%s).', $this->getUser()->getGuardUser()->getId())); $this->form = new sfGuardUserForm($sf_guard_user);
}
public function executeUpdate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod('post') || $request->isMethod('put'));
$this->forward404Unless($sf_guard_user = sfGuardUserPeer
::retrieveByPk($this->getUser()->getGuardUser()->getId()), sprintf('Object sf_guard_user does not exist (%s).', $this->getUser()->getGuardUser()->getId())); $this->form = new sfGuardUserForm($sf_guard_user);
$this->processForm($request, $this->form);
$this->setTemplate('Edit');
}
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
$sf_guard_user->setPassword($form->getValue('password'));
$form->save();
$sf_guard_user->save();
$this->redirect('homepage');
}
}
?>
formularz:
<?php
class sfGuardUserForm extends BasesfGuardUserForm
{
protected
$pkName = null;
public function configure()
{
$this['last_login'],
$this['created_at'],
$this['salt'],
$this['algorithm'],
$this['is_active'],
$this['is_super_admin'],
$this['sf_guard_user_group_list'],
$this['sf_guard_user_permission_list']
);
$this->widgetSchema['password'] = new sfWidgetFormInputPassword();
$this->widgetSchema['password_new_again'] = new sfWidgetFormInputPassword();
$this->widgetSchema['password_old'] = new sfWidgetFormInputPassword();
$this->validatorSchema['password'] = new sfValidatorString
(array('required' => true, 'min_length' => 6, 'max_length' => 255
),array('required' => 'Wypełnij pole.', 'min_length' => 'Minimalna długość hasła to %min_length% znaków', 'max_length' => 'Maksymalna długość hasła to %max_length% znaków')); $this->validatorSchema['password_new_again'] = new sfValidatorString
(array('required' => true, 'min_length' => 6, 'max_length' => 255
),array('required' => 'Wypełnij pole.', 'min_length' => 'Minimalna długość hasła to %min_length% znaków', 'max_length' => 'Maksymalna długość hasła to %max_length% znaków')); $this->validatorSchema['password_old'] = new sfValidatorString
(array('required' => true, 'min_length' => 6, 'max_length' => 255
),array('required' => 'Wypełnij pole.', 'min_length' => 'Minimalna długość hasła to %min_length% znaków', 'max_length' => 'Maksymalna długość hasła to %max_length% znaków'));
$this->mergePostValidator(new sfValidatorSchemaCompare
('password', sfValidatorSchemaCompare
::EQUAL, 'password_new_again', array(), array('invalid' => 'Podane hasła muszą być takie same!')));
$this->mergePostValidator(new sfValidatorSchemaCompare
('password', sfValidatorSchemaCompare
::NOT_EQUAL, 'password_old', array(), array('invalid' => 'Wprowadź nowe hasło!')));
//$this->widgetSchema->moveField('password', 'after', 'email_again');
$this->widgetSchema->setLabels(array( 'password' => 'Nowe hasło: ',
'password_new_again' => 'Powtórz nowe hasło: ',
'password_old' => 'Wpisz stare hasło: '
));
$this->widgetSchema->setNameFormat('passwordchange[%s]');
}
}
?>