简体   繁体   English

FOSUserBundle编辑EDITPAGE PROFILE

[英]FOSUserBundle edit EDITPAGE PROFILE

This is my code : 这是我的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>

When I click submit button, my profil have no change :( 当我点击提交按钮时,我的个人资料没有变化:(

but when I change my code by this code: 但是当我通过这段代码更改我的代码时:

<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>

Why ? 为什么? What should I do? 我该怎么办?

Thank you so much. 非常感谢。

Have you referred to http://symfony.com/doc/current/form/form_customization.html ? 你有没有提到http://symfony.com/doc/current/form/form_customization.html Havent worked with symfony for a while now, but as far as i remember, the following is the proper way to go. 没有和symfony合作过一段时间,但据我记忆,以下是正确的方法。 Can you please check if it works? 你能检查它是否有效吗?

{{ 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) }}

Are there any errors rendered? 是否有任何错误呈现? (and does form_rest render any more fields? Maybe your original code had errors, because there were more required fields in fosuserbundle that were required but you were not including those fields in your form) (并且form_rest是否form_rest渲染更多字段?也许您的原始代码有错误,因为fosuserbundle中有更多必需字段是必需的,但您没有在表单中包含这些字段)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM