Symfony的表单值丢失 [英] Symfony form values missing

查看:142
本文介绍了Symfony的表单值丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个简单的登录表单,一切工作正常(验证等),但我不能让价值观,还有我的code:

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');
          }
      }
  }

$这个 - >登录为NULL。现在,我检查了几乎所有的东西,形式是有效的,一个isBound()为真,COUNT()返回3,我可以看到我的请求,值:

$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​​()返回NULL,的getValue('密码')等返回NULL为好。这怎么可能呢?

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

不,我不想用sfGuard-插件;)

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

推荐答案

关于尝试这样的事情是什么

What about trying something like this

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

这还算是NULL?

Is it still NULL?

也有可能是您创建了一个自定义后验证?

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

这篇关于Symfony的表单值丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆