致命错误:找不到类'Symfony \ Component \ Form'

时间:2011-03-03 09:09:35

标签: symfony symfony-forms

当我为用户创建表单时。它显示以下错误

Fatal error: Class 'Symfony\Component\Form' not found in D:\wamp\www\sandbox\src\Sensio\HelloBundle\User\UserForm.php on line 7"

以下是UserForm.php的代码

<?php

use Symfony\Component\Form;
use Symfony\Component\Form\TextField;
use Symfony\Component\Form\EmailField;

class UserForm extends Form
{
    protected function configure()
    {
        $this->add(
               new TextField('name',
                               array('max_length' => 100,
                                   'required' => true
                                   )
                         )
              );
        $this->add(
               new EmailField('email',
                               array('max_length' => 100,
                                   'required' => true
                                   )
                         )
              );
    }
}

2 个答案:

答案 0 :(得分:1)

将'使用Symfony \ Component \ Form'替换为'使用Symfony \ Component \ Form \ Form'(第3行)。

答案 1 :(得分:0)

如果你要

致命错误:Class&#39; UsersForm&#39;在symfony中找不到

class contactActions extends sfActions
{
    public function executeIndex()
    {
        $this->form = new ContactForm();
    }
}

使用以下命令:

$ php symfony cc

OR

$ php symfony cache:clear