3

I was writing a simple login form, everything works fine (validation etc.) but I can't get the values, there's my code:

public function executeIndex(sfWebRequest $request)
  {
      $this->getUser()->clearCredentials();
      $this->getUser()->setAuthenticated(false);

      $this->form = new LoginForm();

      if ($request->isMethod('post') && $request->hasParameter('login')) {
          $this->form->bind($request->getParameter('login'));

          if ($this->form->isValid()) {

              $this->getUser()->setAuthenticated(true);
              $this->getUser()->addCredential('user');
              $this->login = $this->form->getValue('login');
          }
      }
  }

$this->login is NULL. Now I checked almost everything, the form is valid, isBound() is true, count() returns 3, I can see the values in my request:

parameterHolder:
  action: index
  login: { login: foo, password: foo, _csrf_token: 53ebddee1883d7e3d6575d6fb1707a15 }
  module: login

BUT getValues() returns NULL, getValue('login') etc. returns NULL as well. How can it be?

And no, I don't want to use sfGuard-Plugins ;)

2 Answers 2

4

What about trying something like this

$form['value_name']->getValue()

Is it still NULL?

Also is it possible that you created a custom post validator?

Sign up to request clarification or add additional context in comments.

3 Comments

wow, it works that way, thanks! and yes, i created a post validator to check login & pass in the db...
I was asking because it might be possible that something is wrong with your validator or that it isn't returning anything at all so you're getting a NULL value
It is interesting why $form['name']->getValue(), but form->getValue('name') and $form->getValues() doesn't work...
1

Callback validation must return values back to caller:

return $values;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.