php – FosUserbundle和symfony 2模板和编辑
作者:互联网
我是symfony 2的新手.我刚安装了基本的FOSuserbundle.但我有一些问题:
>我已经设置了新的布局模板,但我无法找到更改登录,注册,配置文件的表单模板的位置
>我找不到如何编辑用户个人资料.我可以使用/ profile查看配置文件,但我找不到任何编辑链接
解决方法:
您可以在documentation内找到问题的答案.以下是一些要点:
>将要从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
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')
;
}
}
标签:php,symfony,fosuserbundle 来源: https://codeday.me/bug/20191007/1864678.html