Symfony2 bindrequest error
- by user1321109
namespace Topxia\LiftBundle\Form;
use Symfony\Component\Validator\Constraint as Assert;
class AddUser {
/**
* @Assert\NotBlank(message="???????")
*/
public $username;
/**
* @Assert\NotBlank(message="????????")
*/
public $name;
/**
* @Assert\NotBlank(message="??????")
* @Assert\MinLength(limit=4,message="?????")
* @Assert\MaxLength(limit=24,message="?????")
*/
public $password;
/**
* @Assert\NotBlank(message="??????")
*/
public $rpassword;
/**
* @Assert\NotBlank(message="???????")
* @Assert\Email(message="???????")
*/
public $email;
/**
* @Assert\NotBlank(message="k3????????")
*/
public $num;
/**
* @Assert\NotBlank()
* @Assert\Choice({"0", "1", "2", "3", "4"})
*/
public $roles;
public $changePassword;
}
namespace Topxia\LiftBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class AddUserType extends AbstractType{
public function buildForm(FormBuilder $builder, array $options){
$builder->add('username', 'text', array('label' => '????'));
$builder->add('name', 'text', array('label' => '???'));
$builder->add('password', 'password', array('label' => '??'));
$builder->add('rpassword', 'password', array('label' => '????'));
$builder->add('email', 'email', array('label' => '??'));
$builder->add('num', 'text', array('label' => 'K3????'));
$builder->add('roles', 'choice', array('label' => '???', 'multiple' => false, 'expanded' => true,
'choices' => array(
'0' => '?????',
'1' => '?????',
'2' => '?????',
'3' => '???',
'4' => '???'
),
));
$builder->add('changePassword', 'checkbox', array('label' => '??????', 'value' => '1'));
}
public function getName(){
return 'add_user';
}
}
when i use $form-bindRequest($request); in conctollor there is an error :
[Semantical Error] The annotation "@Symfony\Component\Validator\Constraint\NotBlank" in property Topxia\LiftBundle\Form\AddUser::$username does not exist, or could not be auto-loaded.
500 Internal Server Error - AnnotationException
I have no idea about this.
Thanks