【发布时间】:2013-09-30 08:31:32
【问题描述】:
我正在使用 symfony2 和 FOSUserBundle
我想在 ProfileController 中使用“createFormBuilder”
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Acme\UserBundle\Entity\AttrMutor;
class ProfileController extends ContainerAware
{
$attrMutor = new AttrMutor();
$form = $this->createFormBuilder($attrMutor);
它显示如
FatalErrorException: Error: Call to undefined method Acme\UserBundle\Controller\ProfileController::createFormBuilder()
我该如何解决这个问题?
我可以在其他 Controller 中使用 $this->createFormBuilder,例如
class DefaultController extends Controller
{
$attrMutor = new AttrMutor();
$form = $this->createFormBuilder($attrMutor); //OK
我认为 extends ContainerAware 和 extends Controller 之间存在一些差异
【问题讨论】:
标签: symfony