2014-01-15 94 views
1

我在這裏處理的東西很愚蠢(我認爲)。我正在Symfony2項目中使用PUGXMultiUserBundle,但是提交一個註冊表單(對於我的每個註冊表單類型)使我回到相同的表單,並且我不知道我在做什麼錯誤。PUGXMultiUserBundle表單提交返回到表單,數據庫不變(Symfony2)

假設我已經按照PUGXMultiUserBundle文檔(https://github.com/PUGX/PUGXMultiUserBundle/blob/master/Resources/doc/index.md)的「成功」步驟1..6進行操作,並且具有上述行爲...我在哪裏混亂得如此嚴重?

* PUGXMultiUserBundle代碼和行爲遍佈在許多文件中,我會提供您需要幫助識別問題的代碼,如果我們可以將它圈選到某個部分。

在此先感謝!

+0

好吧,原來它不是一個捆綁的東西,更多的是形式呈現的東西。當我在註冊模板的末尾渲染一個{{form_rest(form)}}時,它運行良好,但是當我渲染{{form_widget(form._token)}}(而不是其他的)時,它的行爲就像我解釋的。因爲我不想渲染窗體中的所有字段(我在setEmail和setEmailCanonical方法的電子郵件後設置了用戶名,但用戶不需要輸入),這對我來說是一個問題。我將在此發佈另一個問題。謝謝你們。 – tasugo

+0

這是新的問題:http://stackoverflow.com/questions/21136201/fosuserbundle-twig-form-submit-not-expected-behaviour謝謝。 – tasugo

回答

0

請確保您已設置正確的路線:

# Acme/UserBundle/Resources/config/routing.yml 
user_one_registration: 
    pattern: /register/user-one 
    defaults: { _controller: AcmeUserBundle:RegistrationUserOne:register } 

user_two_registration: 
    pattern: /register/user-two 
    defaults: { _controller: AcmeUserBundle:RegistrationUserTwo:register } 

當你走在/register/user-one,你應該看到:

AcmeUserBundle:Registration:user_one.form.html.twig,當你走在/register/user-two,你應該看到AcmeUserBundle:Registration:user_two.form.html.twig

我有一種感覺,你的錯誤是在您的模板:

所以,當您在您的視圖提交表單,你必須將其提交給正確的方法:

AcmeUserBundle:Registration:user_one.form.html.twig

<form action="{{ path('user_one_registration') }}" {{ form_enctype(form) }} method="POST"> 

AcmeUserBundle:Registration:user_two.form.html.twig

<form action="{{ path('user_two_registration') }}" {{ form_enctype(form) }} method="POST"> 
+0

感謝您的回覆。我想,我有這個權利。除了兩個操作(registerUserOneAction和registerUserTwoAction)都存在於同一個控制器中。這可能是一個問題嗎?否則,我說得對。 – tasugo

+0

您需要[兩個控制器](https://github.com/PUGX/PUGXMultiUserBundle/blob/master/Resources/doc/index.md#controllers)'RegistrationUserOneController'和'RegistrationUserTwoController'。因爲這與'register'的方法相同。 – Mick

+0

試過了,沒有運氣。我的路線看起來像MyBundle:SameController:registerUserOne和MyBundle:SameController:registerUserTwo。這兩個行動都是作爲文件狀態。還是同樣的問題。 – tasugo