FOSUserBundle编辑EDITPAGE PROFILE

时间:2017-03-29 01:32:00

标签: php symfony

这是我的 private void usingmltBtn_Click(object sender, RoutedEventArgs e) { if (RadioButton.IsChecked == true) { RadioButton.IsChecked = false; i2cerrRec.Visibility = Visibility.Collapsed; i2cerrTxt.Visibility = Visibility.Collapsed; mltI2Cnck = 0; } else if (RadioButton.IsChecked == false) { RadioButton.IsChecked = true; mlttempLbl.Text = "N/C"; } }

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>

为什么? 我该怎么办?

非常感谢你。

1 个答案:

答案 0 :(得分:0)

你有没有提到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是否会渲染更多字段?也许您的原始代码有错误,因为fosuserbundle中有更多必需字段,但您没有在表单中包含这些字段)