When a company registers they insert his main office adress data. This data is simply saved in a USer entity. However, If the company has more offices he should be able to add them on the same form, but to a different entity. Is that even possible? If not, what are the options.
For example:
When a user goes to registration the form opens:
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
->add('country', 'country', array(
'label' => 'form.label.country',
'required' => false,
))
->add('town', 'text', array(
'label' => 'form.label.town',
'required' => false,
))
>add('residence', 'text', array(
'label' => 'form.label.adress',
'required' => false,
))
->add('zip', 'text', array(
'label' => 'form.label.zip',
'required' => false,
))
This is saved in a User class.
If a user has more offices additional fields should appear that store the new data to a different entity.
UserAdress entity:
class UserAdress
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="id_user", type="integer")
*/
private $idUser;
/**
* @var string
*
* @ORM\Column(name="office_name", type="string", length=255)
*/
private $officeName;
/**
* @var string
*
* @ORM\Column(name="Adress", type="string", length=255)
*/
private $adress;
/**
* @var string
*
* @ORM\Column(name="country", type="string", length=255)
*/
private $country;
/**
* @var string
*
* @ORM\Column(name="town", type="string", length=255)
*/
private $town;
/**
* @var string
*
* @ORM\Column(name="zip", type="string", length=255)
*/
private $zip;
Now I need to render a new form with these fields in the same registration form... Is that possible?