Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony] setPassword - nie dziala?
janek9
post
Post #1





Grupa: Zarejestrowani
Postów: 121
Pomógł: 2
Dołączył: 22.03.2009

Ostrzeżenie: (0%)
-----


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

  1. <?php
  2. public function executeEdit(sfWebRequest $request)
  3.  {
  4.    $this->forward404Unless($sf_guard_user = sfGuardUserPeer::retrieveByPk($this->getUser()->getGuardUser()->getId()), sprintf('Object sf_guard_user does not exist (%s).', $this->getUser()->getGuardUser()->getId()));
  5.    $this->form = new sfGuardUserForm($sf_guard_user);
  6.  }
  7.  
  8.  public function executeUpdate(sfWebRequest $request)
  9.  {
  10.    $this->forward404Unless($request->isMethod('post') || $request->isMethod('put'));
  11.    $this->forward404Unless($sf_guard_user = sfGuardUserPeer::retrieveByPk($this->getUser()->getGuardUser()->getId()), sprintf('Object sf_guard_user does not exist (%s).', $this->getUser()->getGuardUser()->getId()));
  12.    $this->form = new sfGuardUserForm($sf_guard_user);
  13.  
  14.    $this->processForm($request, $this->form);
  15.  
  16.    $this->setTemplate('Edit');
  17.  }
  18.  
  19. protected function processForm(sfWebRequest $request, sfForm $form)
  20.  {
  21.    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
  22.    if ($form->isValid())
  23.    {
  24.      $sf_guard_user->setPassword($form->getValue('password'));
  25.    $form->save();
  26.      $sf_guard_user->save();
  27.  
  28.      $this->redirect('homepage');
  29.    }
  30.  }
  31. ?>


formularz:

  1. <?php
  2. class sfGuardUserForm extends BasesfGuardUserForm
  3. {
  4.  protected
  5.    $pkName = null;
  6.  
  7.  public function configure()
  8.  {
  9.    
  10.  
  11.    unset(
  12.      $this['last_login'],
  13.      $this['created_at'],
  14.      $this['salt'],
  15.      $this['algorithm'],
  16.      $this['is_active'],
  17.      $this['is_super_admin'],
  18.      $this['sf_guard_user_group_list'],
  19.      $this['sf_guard_user_permission_list']
  20.    );
  21.  
  22.    $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
  23.    $this->widgetSchema['password_new_again'] = new sfWidgetFormInputPassword();
  24.    $this->widgetSchema['password_old'] = new sfWidgetFormInputPassword();
  25.  
  26.    $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'));
  27.    $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'));
  28.    $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'));
  29.    
  30.        $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_new_again', array(), array('invalid' => 'Podane hasła muszą być takie same!')));
  31.  
  32.    $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::NOT_EQUAL, 'password_old', array(), array('invalid' => 'Wprowadź nowe hasło!')));
  33.  
  34.    
  35.  
  36.    //$this->widgetSchema->moveField('password', 'after', 'email_again');
  37.  
  38.    $this->widgetSchema->setLabels(array(
  39.    'password' => 'Nowe hasło: ',
  40.        'password_new_again' => 'Powtórz nowe hasło: ',
  41.        'password_old' => 'Wpisz stare hasło: '
  42.    ));
  43.  
  44.        
  45.    
  46.      
  47.      $this->widgetSchema->setNameFormat('passwordchange[%s]');
  48.  }
  49. }
  50. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 09:46