Quite easy in fact, I did not know it was possible to add another FormType as a field type in Symfony2.
The working way, just in case :
namespace MyAdminBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class SecretaryType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('employee', new EmployeeType(), array('label' => 'Employee', 'required' => true))
->add('password', 'password', array('label' => 'Password', 'required' => true))
;
}
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'MyCoreBundle\Entity\Secretary'
));
}
/**
* @return string
*/
public function getName()
{
return 'my_adminbundle_secretary';
}
}