【发布时间】:2012-01-12 04:42:59
【问题描述】:
我是 symfony 2 的新手。我刚刚安装了基本的 FOSuserbundle。但我有几个问题:
我已经设置了新的布局模板,但是我找不到在哪里更改用于登录、注册、个人资料的表单模板
我找不到如何编辑用户配置文件。我可以使用 /profile 查看个人资料,但在那里找不到任何编辑链接
【问题讨论】:
标签: php symfony fosuserbundle
我是 symfony 2 的新手。我刚刚安装了基本的 FOSuserbundle。但我有几个问题:
我已经设置了新的布局模板,但是我找不到在哪里更改用于登录、注册、个人资料的表单模板
我找不到如何编辑用户配置文件。我可以使用 /profile 查看个人资料,但在那里找不到任何编辑链接
【问题讨论】:
标签: php symfony fosuserbundle
您可以在documentation 中找到有关您的问题的答案。以下是几点:
FOSUserBundle/Resources/views 复制到您的捆绑包中,然后进行所需的更改。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
<?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')
;
}
}
【讨论】:
vendor/bundles/FOS/UserBundle/Resources/config/routing/profile.xml里面
@Anton 有您问题第一部分的正确答案,但要回答第二部分,如果您可以从 /profile 查看您的个人资料,您可以在浏览器中转到 /profile/edit 进行编辑。
默认配置文件表单上没有编辑链接。如果你想要一个,你需要听取@Anton 的建议,复制默认的表单模板并将它们粘贴到包中同名的目录中。
正如@Anton 已经指出的那样,有关如何执行此操作的所有详细信息都在master documentation 或documentation for version 1.2.0 中(如果您使用的是 Symfony 2.0,您将需要它们。*
【讨论】: