簡體   English   中英

FOSUserBundle編輯EDITPAGE PROFILE

[英]FOSUserBundle edit EDITPAGE PROFILE

這是我的code

<form action="{{ path('fos_user_profile_edit') }}" {{ form_enctype(form) }} method="POST" class="fos_user_profile_edit">            
    <div class="edittext_registre1">{{ form_label(form.username) }}</div>
    <div class="editbox_registre1">{{ form_widget(form.username) }}</div>
    <br/><br/>
    <div class="edittext_registre2">{{ form_label(form.email) }}</div>
    <div class="editbox_registre2">{{ form_widget(form.email) }}</div>
    <br/><br/>
    <div class="edittext_registre3">{{ form_label(form.current_password) }}</div>
    <div class="editbox_registre3">{{ form_widget(form.current_password) }}</div>
    <br/><br/>
    <div>
        <input type="submit" value="{{ 'profile.edit.submit'| trans }}" />
    </div>
</form>

當我點擊提交按鈕時,我的個人資料沒有變化:(

但是當我通過這段代碼更改我的代碼時:

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


    {% include "FOSUserBundle:Profile:edit_content.html.twig" %}

    <div>
        <input type="submit" value="{{ 'profile.edit.submit'| trans }}" />
    </div>
</form>

為什么? 我該怎么辦?

非常感謝。

你有沒有提到http://symfony.com/doc/current/form/form_customization.html 沒有和symfony合作過一段時間,但據我記憶,以下是正確的方法。 你能檢查它是否有效嗎?

{{ form_start(form, { 'action': path('fos_user_profile_edit'), 'attr': { 'class': 'fos_user_profile_edit' } }) }}
  <div class="edittext_registre1">
    {{ form_label(form.username) }}
  </div>
  <div class="editbox_registre1">
    {{ form_errors(form.username) }}
    {{ form_widget(form.username) }}
  </div>
  <br/>
  <br/>
  <div class="edittext_registre2">
    {{ form_label(form.email) }}
  </div>
  <div class="editbox_registre2">
    {{ form_errors(form.email) }}
    {{ form_widget(form.email) }}
  </div>
  <br/>
  <br/>
  <div class="edittext_registre3">
    {{ form_label(form.current_password) }}
  </div>
  <div class="editbox_registre3">
    {{ form_errors(form.current_password) }}
    {{ form_widget(form.current_password) }}
  </div>
  <br/>
  <br/>
  {{ form_rest(form) }}
  <div>
    <input type="submit" value="{{ 'profile.edit.submit'|trans }}" />
  </div>
{{ form_end(form) }}

是否有任何錯誤呈現? (並且form_rest是否form_rest渲染更多字段?也許您的原始代碼有錯誤,因為fosuserbundle中有更多必需字段是必需的,但您沒有在表單中包含這些字段)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM