问题描述
我是Symfony 2的新手.我刚刚使用基本的FosuserBundle设置.但是我有一些问题:
推荐答案
在您的问题上的答案您可以在文档 .这是一些要点:
- 复制模板您要从FOSUserBundle/Resources/views修改为捆绑包并进行您想要的更改.
- 如果您需要制作自定义配置文件表格(我猜是基于您的问题),则必须创建配置文件表单类型并指定FosuserBundle使用它.
config.yml
services: my_user.profile.form.type: class: My\UserBundle\Form\Type\ProfileFormType arguments: [%fos_user.model.user.class%] tags: - { name: form.type, alias: my_user_profile } fos_user: profile: form: type: my_user_profile
profiolformtype.php
<?php namespace My\UserBundle\Form\Type; use Symfony\Component\Form\FormBuilder; use FOS\UserBundle\Form\Type\ProfileFormType as BaseType; class ProfileFormType extends BaseType { public function getName() { return 'my_user_profile'; } protected function buildUserForm(FormBuilder $builder, array $options) { $builder ->add('email', 'email') ->add('firstName') ->add('lastName') ; } }
其他推荐答案
@anton对问题的第一部分有正确的答案,但是要回答第二部分,如果您可以从/profile查看您的配置文件,则可以通过在浏览器中转到/profile/edit来编辑.<<<<<<<<<<<<<<<
默认配置文件表单上没有编辑链接.如果您想要一个,您需要获取@anton的建议并复制默认表单模板,然后将它们粘贴到捆绑包中具有相同名称的目录中.
正如@anton已经指出的那样,有关如何执行此操作的所有详细信息都是在主文档或版本1.2.0的文档(如果使用Symfony 2.0,则需要它.*
问题描述
I am new to symfony 2. I have just setup with basic FOSuserbundle. But I have a few problems:
I have setup the new layout template but I could not find where to change the form template for login, registration, profile
I could not find how to edit the user profile. I can view the profile using /profile but I could not find any edit link there
推荐答案
Answers on your questions you can find inside documentation. Here are some points:
- Copy templates you want to modify from FOSUserBundle/Resources/views into your bundle and do changes you want.
- If you need to make a custom profile form (as I guess based on your question), then you have to create profile form type and specify that FOSUserBundle uses it.
config.yml
services: my_user.profile.form.type: class: My\UserBundle\Form\Type\ProfileFormType arguments: [%fos_user.model.user.class%] tags: - { name: form.type, alias: my_user_profile } fos_user: profile: form: type: my_user_profile
ProfileFormType.php
<?php namespace My\UserBundle\Form\Type; use Symfony\Component\Form\FormBuilder; use FOS\UserBundle\Form\Type\ProfileFormType as BaseType; class ProfileFormType extends BaseType { public function getName() { return 'my_user_profile'; } protected function buildUserForm(FormBuilder $builder, array $options) { $builder ->add('email', 'email') ->add('firstName') ->add('lastName') ; } }
其他推荐答案
@Anton has the correct answer for the first part of your question but to answer the second part, if you can view your profile from /profile you can edit by going to /profile/edit in your browser.
There is no edit link on the default profile form. If you want one, you'll need to take the advice of @Anton and copy the default form template(s) and paste them into a directory with the same name in your bundle.
As @Anton already pointed out, all of the details on how to do this are in either the master documentation or the documentation for version 1.2.0 (which you will need if you are using Symfony 2.0.*