Symfony2 bindrequest error

Posted by user1321109 on Stack Overflow See other posts from Stack Overflow or by user1321109
Published on 2012-04-09T03:43:28Z Indexed on 2012/04/09 5:28 UTC
Read the original article Hit count: 372

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about forms

Related posts about symfony-2.0