dongma1666 2017-03-29 01:31
浏览 23
已采纳

FOSUserBundle编辑EDITPAGE PROFILE

This is my 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.

  • 写回答

1条回答 默认 最新

  • dsjk3214 2017-03-29 02:06
    关注

    Have you referred to 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. 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)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧