Symfony2嵌入了所有FOSUserBundle表单(Symfony2 embed all FOSUserBundle forms)

我正在尝试将所有FOSUserBundle表单嵌入到布局左侧的侧边栏中。

这是我的src/My/MainBundle/Resources/config/routing.yml

index:
    pattern: /
    defaults: { _controller: MyMainBundle:Main:index }

login:
    pattern: /login
    defaults: { _controller: MyMainBundle:Main:index }

resetting_request:
    pattern: /resetting/request
    defaults: { _controller: MyMainBundle:Main:index }

resetting_send_email:
    pattern: /resetting/send-email
    defaults: { _controller: MyMainBundle:Main:index }

src/My/MainBundle/Resources/views/layout.html.twig ,我有(除其他外):

<div id="sidebar">
    {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
        <p>You are logged in blah blah blah</p>
    {% elseif app.request.attributes.get('_route') == 'resetting_request' %}
        {{ render(controller('FOSUserBundle:Resetting:request')) }}
    {% elseif app.request.attributes.get('_route') == 'resetting_send_email' %}
        {{ render(controller('FOSUserBundle:Resetting:sendEmail')) }}
    {% else %}
        {{ render(controller('FOSUserBundle:Security:login')) }}
    {% endif %}
</div>

登录表单工作正常,它提交到/ login_check,然后重定向到请求的页面,如果登录名和密码是正确的,或者,如果登录名或密码错误,它会重定向到/ login(在这种情况下,它正确在侧栏中显示表单,并显示相应的错误消息)。

我在“忘记密码?”时遇到问题。 但形式。

它显示在侧边栏中,并提交/重置/发送电子邮件,但它不会重定向到任何内容。 然后它告诉我用户名或电子邮件“”不存在。

如果我评论“resetting_send_email”路由,那么“发送电子邮件”操作有效,但输出不在侧边栏中(事实上,它周围甚至没有布局)。

有任何想法吗?


I'm trying to embed all FOSUserBundle forms in a sidebar on the left of my layout.

Here's my src/My/MainBundle/Resources/config/routing.yml:

index:
    pattern: /
    defaults: { _controller: MyMainBundle:Main:index }

login:
    pattern: /login
    defaults: { _controller: MyMainBundle:Main:index }

resetting_request:
    pattern: /resetting/request
    defaults: { _controller: MyMainBundle:Main:index }

resetting_send_email:
    pattern: /resetting/send-email
    defaults: { _controller: MyMainBundle:Main:index }

In src/My/MainBundle/Resources/views/layout.html.twig, I have (among other things):

<div id="sidebar">
    {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
        <p>You are logged in blah blah blah</p>
    {% elseif app.request.attributes.get('_route') == 'resetting_request' %}
        {{ render(controller('FOSUserBundle:Resetting:request')) }}
    {% elseif app.request.attributes.get('_route') == 'resetting_send_email' %}
        {{ render(controller('FOSUserBundle:Resetting:sendEmail')) }}
    {% else %}
        {{ render(controller('FOSUserBundle:Security:login')) }}
    {% endif %}
</div>

The login form works fine, it submits to /login_check, which then redirects to the page that was requested, if the login and password are correct, or, it redirects to /login if the login or password are wrong (in that case it correctly displays the form in the sidebar, with the corresponding error message).

I'm having trouble with the "Forgot password?" form, though.

It shows up in the sidebar, and submits to /resetting/send-email, but then it doesn't redirect to anything. It then tells me that the username or email "" doesn't exist.

If I comment the "resetting_send_email" route, then the "send email" action works, but the output is not in the sidebar (in fact, there isn't even a layout around it).

Any ideas?


原文:https://stackoverflow.com/questions/22507817
2023-10-07 17:10

满意答案

问题是XML。 结构不合理。 我现在改变了结构和工作。

谢谢。


The problem was the XML. It wasn't structured properly. I changed the structure and its working now.

Thank You.

相关问答

更多

OnBackKeyPress未按预期工作(OnBackKeyPress is not working as expected)

由于您在e.cancel = true设置了e.cancel = true ,因此NavigationMode将不会Back OnNavigatedFrom 。 尝试在页面中使用全局变量,默认情况下为false ,并在OnBackKeyPress中将其设置为true 。 然后,在OnNavigatedFrom检查此变量而不是NavigationMode.Back 。 Since you're setting e.cancel = true in OnBackKeyPress, the Naviga...

在Application Engine中使用PeopleCode的Zip文件(Zip Files using PeopleCode in Application Engine)

实际上我们调用java代码来压缩文件。 如: &buffer = CreateJavaArray("byte[]", 18024); &zipStream = CreateJavaObject("java.util.zip.ZipOutputStream", CreateJavaObject("java.io.FileOutputStream", &outDir | &outZip)); For &i = 1 To &inFiles.Len &zipStream...

.get()无法按预期工作(.get() not working as expected)

$.fn.get与$.fn.map一起使用时,返回一个没有addClass和更多jQuery方法的HTMLElement 。 所以你必须使用eq进行以下操作(或者:first根据你的需要) $('.a').eq(0).addClass('g'); // assuming you want first .a 如果你想要一种本地的方式(出于一些奇怪的原因)那么你就可以做到 $('.a').get(0).className += " g"; // space is important -------^...

导航在WinJS中未按预期工作(Navigation not working as expected in WinJS)

WinJS.Navigation命名空间提供状态和历史管理,但它实际上并不执行导航。 要从一个页面移动到另一个页面,您需要为WinJS.Navigation命名空间中的一个事件定义处理函数 - 这使您可以以对您的应用程序有意义的方式响应对WinJS.Navigation.navigate方法的调用。 作为演示,这里是一个homePage.html文件,其中包含一个NavBar,其中包含一个命令,该命令将成为导航的触发器。 <!DOCTYPE html> <html> <head> <met...

原型未按预期工作(Prototype is not working as expected)

new obj(); 返回一个对象而不是一个函数,所以当你调用时 var animal = new obj(); animal变量将填充一个非功能的对象。 这个说法 var dog = new animal(); 返回undefined因为animal不是函数(构造函数)。 请注意,operator new仅用于函数,不适用于文字对象 有关此主题的更多信息,请查看此问题 一个简单的JavaScript继承模式 首先定义一个基类(JS中没有类概念,但为了更方便我使用它) function Obj...

功能未按预期工作(function isn't working as expected)

更改return array($power, $exp-1); return array( pow($base, $exp-1), $exp-1); 您将根据$exp返回$power的$exp ,而不是$exp-1 。 Change return array($power, $exp-1); to return array( pow($base, $exp-1), $exp-1); You are returning the value for $power based on $exp, not ...

intdiv()未按预期工作(intdiv() is not working as expected)

intdiv()是上一份工作的错误工具。 除法的结果将是一个intdiv将转换为0的浮点数。 代码:( 演示 ) function getyearly($monthly, $yearly) { if(!empty($monthly) && !empty($yearly)) { $permonth=intdiv((int)$yearly, 12); echo "Single payment will feel like 12-monthly payments ...

peoplecode中的LoadXMLString函数未按预期工作(LoadXMLString function in peoplecode not working as expected)

问题是XML。 结构不合理。 我现在改变了结构和工作。 谢谢。 The problem was the XML. It wasn't structured properly. I changed the structure and its working now. Thank You.

使用Java类在PeopleCode中调用多个CI(Invoking Multiple CI's within PeopleCode using Java Classes)

在与建筑师讨论并获得他们的反馈之后。 以异步方式发送消息绝对没问题。 我们可以让应用程序引擎成功,然后我们可以填充物理表,因为我们不断消耗消息并相应地更新每行的状态,而不是让应用程序引擎在一切都完成之前进入休眠状态。 感谢这个精彩的社区,我希望这个主题可以帮助任何可以从这种方法中受益的人。 After discussing it with the architects and getting their feedback. It is absolutely fine to send the mes...

Scala中的隐式函数未按预期工作(Implicit function in Scala not working as expected)

[T <: Number]类型边界意味着T必须是Number的子类型 。 从Int到Integer的隐式转换并没有给你这个,因为即使转换可用,它仍然不意味着Int是Number的子类型。 幸运的是,有一个类似的称为视图边界的东西,写成[T <% Number] ,它准确指定了你想要的东西,有一个从T到Number的隐式转换 The [T <: Number] type bounds means that T must be a subtype of Number. The implicit con...

相关文章

更多

Symfony2网站开发

http://blog.csdn.net/liubei5/article/details/132902 ...

我是如何在15天开发出一个网站的

最近历经半个月开发了一个新的网站 湖南英才网 ,这是我个人开发的第N个独立网站了,不过和往常不同的是, ...

强力推荐几款JS插件,

强力推荐几款JS插件, Advanced Register/Signup ...

HTML5 智能form表单新属性

内容摘要:HTML5 智能form表单新属性,主要包括智能表单介绍和智能表单使用与规范。但在不同支持H ...

HTML5项目笔记2:离线系统表单设计

在这个离线系统中,表单无疑是构成这个离线系统的视图部分,作为最前端,与客户的操作最密切相关的一块,所以 ...

swing 嵌入 网页中

我想把我做的swing嵌入至网页中,请问该如何操作呢?

获得表单里的值

请问大家 我一个页面有两个表单,怎么获得其中一个表单里的所有输入框里的值? 问题补充: ...

HMTL 表单标签

form表单标签: 要提交的内容,使用该标签包裹 action属性: 决定表单提交到哪里 ...

深入了解Activiti工作流流程定义

部署流程定义 部署流程定义的流程: 1. 先获取流程引擎对象:在创建时会自动加载 cla ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本