I'm trying to integrate FOSUserBundle in my web application (symfony based). My application needs to have two different registration forms; one for company profile and one for simple user profile. I would like to have User entity from FOSUserBundle separated to company entity. I tried to extend company from user entity; in this way, it's easy to create a RegistrationFormType like this:
```
class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
// add your custom field
$builder->add('name');
$builder->add('works', 'entity', array(
'class' => 'SkaLabFrontEndBundle:Works',
'property' => 'name'
));
$builder->add('address');
....
}
$builder->add('email');
$builder->add('username');
$builder->add('plainPassword', 'repeated', array(
'type' => 'password',
'invalid_message' => 'The password fields must match.',
'options' => array('attr' => array('class' => 'password-field')),
'required' => true,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Repeat Password')));
}
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'SkaLab\Bundle\UserBundle\Entity\User'
));
}
public function getName()
{
return 'skalab_bundle_userbundle_registration_form';
}
}
But i don't want to extend company from user entity because in this way, when i launch the follow command:
php app/console doctrine:schema:update --force
to update db schema, it should put fos user fields in company table. Insteed, i would like to keep user table (fos_user) separated from company table and to do an one-to-one relationship between company and user table. Obviously, registration form needs to have fields related with user and company table.
How can i do to implement something like that?