English 中文(简体)
edit profile from frontend - symfony
原标题:

I succeeded to create a register form, and now users can register my site. But I can t create a form where users can edit their profile.

I have sf_guard_user and sf_guard_user_profile in my schema.yml

Does someone have an article about how to do that ? I tried few ideas without success.

最佳回答

The quick way to start is to create a frontend CRUD with the task

./symfony doctrine:generate-crud ie.

./symfony doctrine:generate-crud frontend user sfGuardUser

(or you can just generate the profile form with the doctrine:build-forms task)

From here you can customize the form. The most tricky part will be merging the two forms, the sf_gurd_user_form (the one with the password and the username) and the sf_guard_profile_form. If you want profile fields and user fields on the same form you should use embedded forms as stated here:

http://www.blogs.uni-osnabrueck.de/rotapken/2009/03/13/symfony-merge-embedded-form/comment-page-1/

A snippet from that blog page:

class sfGuardUserForm extends BasesfGuardUserForm
{
  public function configure()
  {
    parent::configure();
    $profileForm = new UserProfileForm($this->object->Profile);
    unset ($profileForm[ id ], $profileForm[ sf_guard_user_id ]);
    $this->embedForm("profile", $profileForm);
  }
}
问题回答

暂无回答




相关问题
Natural language rendering

Do you know any frameworks that implement natural language rendering concept ? I ve found several NLP oriented frameworks like Anthelope or Open NLP but they have only parsers but not renderers or ...

PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

Why does stack get truncated in Exception.StackTrace?

Why does the high part of the stack (in Exception.StackTrace) gets truncated? Let s see a simple example: public void ExternalMethod() { InternalMethod(); } public void InternalMethod() { try ...

Finding the correct Python framework with cmake

I am using the macports version of python on a Snow Leopard computer, and using cmake to build a cross-platform extension to it. I search for the python interpreter and libraries on the system using ...

edit profile from frontend - symfony

I succeeded to create a register form, and now users can register my site. But I can t create a form where users can edit their profile. I have sf_guard_user and sf_guard_user_profile in my schema....

MVC evolution and improvements

I just found the MVC was initially proposed in 88 [here is the pdf file] but unfortunately ASP.NET just recently implement it. Do you know which is the most used MVC design pattern in the our days ...

热门标签