Symfony2 get item type in forms

symfony, symfony-2.1

Solution

Use this:

foreach($form as $key => $per) {
    $per->getConfig()->getType()->getName();
}

Problem

I have a form, and need the field type in the bindrequest, the method getType dont works fine: ``` $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 }} ```

Original source