Symfony\Component\Form\FormBuilder::getTypes PHP Method

getTypes() public method

Returns the types used by this builder.
Deprecation: Deprecated since version 2.1, to be removed in 2.3. Use {@link FormConfigInterface::getType()} instead.
public getTypes ( ) : array
return array An array of FormTypeInterface
    public function getTypes()
    {
        $types = array();

        for ($type = $this->getType(); null !== $type; $type = $type->getParent()) {
            array_unshift($types, $type->getInnerType());
        }

        return $types;
    }

Usage Example

 /**
  * @param \Symfony\Component\Form\FormBuilder $formBuilder
  * @return string
  */
 protected function getClass(FormBuilder $formBuilder)
 {
     foreach ($formBuilder->getTypes() as $type) {
         if (isset($this->defaultClasses[$type->getName()])) {
             return $this->defaultClasses[$type->getName()];
         }
     }
     return '';
 }