Symfony的表单值丢失

编程入门 行业动态 更新时间:2024-10-28 01:12:51
本文介绍了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的表单值丢失

本文发布于:2023-10-10 22:55:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479994.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   Symfony

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!