Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 get item type in forms

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
 }}
like image 810
Ciro Vargas Avatar asked Dec 27 '22 15:12

Ciro Vargas


1 Answers

Use this:

foreach($form as $key => $per) {
    $per->getConfig()->getType()->getName();
}
like image 149
Mats Rietdijk Avatar answered Jan 05 '23 10:01

Mats Rietdijk