Symfony2在表单中获取项类型

Cir*_*gas 4 symfony symfony-2.1

我有一个表单,并且需要bindrequest中的字段类型,方法getType不能正常工作:

$peticion = $this->getRequest();
        if ($peticion->getMethod() == 'POST') 
        {
            $form->bindRequest($peticion);

            if ($form->isValid()) {

             foreach($form as $key => $per)
                       $per->getType(); // i want the type of item [text,checkbox,etc] the method getType() dont work
 }}
Run Code Online (Sandbox Code Playgroud)

Mat*_*ijk 10

用这个:

foreach($form as $key => $per) {
    $per->getConfig()->getType()->getName();
}
Run Code Online (Sandbox Code Playgroud)