2013-10-23 140 views

回答

0

創建用於每一個實體延伸AbstractType兩個階級,在第三類中使用它們(也延伸AbstractType)

class AType extends AbstractType { ... } 

class BType extends AbstractType { ... } 

class CType extends AbstractType { 
    public function buildForm(FormBuilderInterface $builder, array $options) 
    { 
     $builder->add('a', new AType(), array(...)); 
     $builder->add('b', new BType(), array(...)); 
    } 
}