title: OroCommerce - Symfony: How to override Entity(Custom Customer Register Account)
body: <p>I’m trying to make a <strong>custom customer register form</strong><br>
  <br>
  And to do so, i’ve to override this 2 file:<br></p>
  
  <p>CustomerBundle\Layout\DataProvider\FrontendCustomerUserRegistrationFormProvider.php<br>
  and<br>
  CustomerBundle\Form\Type\FrontendCustomerUserRegistrationType.php<br></p>
  
  <p>So i’ve put this code in <strong>config/config.yml</strong> and it work as expected:<br></p>
  
  <pre><code>services:
      oro_customer.provider.frontend_customer_user_registration_form:
          class: 'My_Code\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerUserRegistrationFormProvider'
          arguments:
              - "@form.factory"
              - "@doctrine"
              - "@oro_config.manager"
              - "@oro_website.manager"
              - "@oro_user.manager"
              - '@router'
          tags:
              - { name: layout.data_provider, alias: oro_customer_frontend_customer_user_register }
  
      oro_customer.form.type.frontend.customer_user.register:
          class: 'My_Code\Bundle\CustomerBundle\Form\Type\FrontendCustomerUserRegistrationType'
          arguments:
              - '@oro_config.manager'
              - '@oro_user.manager'
          calls:
              - [setDataClass, ['%oro_customer.entity.customer_user.class%']]
          tags:
              - { name: form.type, alias: oro_customer_frontend_customer_user_register }
  </code></pre>
  
  <p>But i also need to override entity as well, so it will render a new column to the customer register form.<br></p>
  
  <p>I’ve notice that <strong>FrontendCustomerUserRegistrationType</strong> have this code:<br></p>
  
  <pre><code>calls:
              - [setDataClass, ['%oro_customer.entity.customer_user.class%']]
  </code></pre>
  
  <p>And so <strong>CustomerBundle\Resources\config\services.yml</strong> have that too:</p>
  
  <pre><code>parameters:
             oro_customer.entity.customer_user.class: Oro\Bundle\CustomerBundle\Entity\CustomerUser
  </code></pre>
  
  <p>So i’ve override it using <strong>config/config.yml</strong>:</p>
  
  <pre><code>parameters:
      oro_customer.entity.customer_user.class: My_Code\Bundle\CustomerBundle\Entity\CustomerUser
  </code></pre>
  
  <p>But it doesn’t work, it throw an error:</p>
  
  <blockquote>
    <p>The form’s view data is expected to be an instance of class
    My_Code\Bundle\CustomerBundle\Entity\CustomerUser, but is an instance
    of class Oro\Bundle\CustomerBundle\Entity\CustomerUser. You can avoid
    this error by setting the “data_class” option to null or by adding a
    view transformer that transforms an instance of class
    Oro\Bundle\CustomerBundle\Entity\CustomerUser to an instance of
    My_Code\Bundle\CustomerBundle\Entity\CustomerUser.</p>
  </blockquote>
  
  <p>I think it make the override of <strong>FrontendCustomerUserRegistrationType</strong> go wrong and failed.<br></p>
  
  <p>Here is my overrided <strong>FrontendCustomerUserRegistrationType.php</strong>:<br></p>
  
  <pre><code>&lt;?php
  
  namespace My_Code\Bundle\CustomerBundle\Form\Type;
  
  use Oro\Bundle\ConfigBundle\Config\ConfigManager;
  use Oro\Bundle\CustomerBundle\Entity\CustomerUser;
  use Oro\Bundle\UserBundle\Entity\User;
  use Oro\Bundle\UserBundle\Entity\UserManager;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\Extension\Core\Type\EmailType;
  use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  use Symfony\Component\Form\Extension\Core\Type\TextType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\Form\FormEvent;
  use Symfony\Component\Form\FormEvents;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  use Symfony\Component\Validator\Constraints as Assert;
  use Oro\Bundle\CustomerBundle\Form\Type\FrontendCustomerUserRegistrationType as OroFrontendCustomerUserRegistrationType;
  
  class FrontendCustomerUserRegistrationType extends OroFrontendCustomerUserRegistrationType
  {
  
      /**
       * @var ConfigManager
       */
      protected $configManager;
  
      /**
       * @param ConfigManager $configManager
       * @param UserManager $userManager
       */
      public function __construct(ConfigManager $configManager, UserManager $userManager)
      {
          parent::__construct($configManager, $userManager);
          $this-&gt;configManager = $configManager;
      }
  
      /**
       * {@inheritdoc}
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          if ($this-&gt;isCompanyNameFieldEnabled()) {
              $builder-&gt;add(
                  'companyName',
                  TextType::class,
                  [
                      'required' =&gt; true,
                      'mapped' =&gt; false,
                      'label' =&gt; 'oro.customer.customeruser.profile.company_name',
                      'constraints' =&gt; [
                          new Assert\NotBlank(),
                          new Assert\Length(['max' =&gt; 255])
                      ],
                      'attr' =&gt; ['placeholder' =&gt; 'oro.customer.customeruser.placeholder.company_name']
                  ]
              );
          }
  
          $builder
              -&gt;add(
                  'firstName',
                  TextType::class,
                  [
                      'required' =&gt; true,
                      'label' =&gt; 'oro.customer.customeruser.first_name.label',
                      'attr' =&gt; ['placeholder' =&gt; 'oro.customer.customeruser.placeholder.first_name']
                  ]
              )
              -&gt;add(
                  'lastName',
                  TextType::class,
                  [
                      'required' =&gt; true,
                      'label' =&gt; 'oro.customer.customeruser.last_name.label',
                      'attr' =&gt; ['placeholder' =&gt; 'oro.customer.customeruser.placeholder.last_name']
                  ]
              )
              -&gt;add(
                  'email',
                  EmailType::class,
                  [
                      'required' =&gt; true,
                      'label' =&gt; 'oro.customer.customeruser.email.label',
                      'attr' =&gt; ['placeholder' =&gt; 'oro.customer.customeruser.placeholder.email']
                  ]
              )
              -&gt;add(
                  'test',
                  TextType::class,
                  [
                      'required' =&gt; true,
                      'label' =&gt; 'Test Label',
                      'attr' =&gt; ['placeholder' =&gt; 'Test Place Holder']
                  ]
              )
              -&gt;add(
                  'test2',
                  TextType::class,
                  [
                      'required' =&gt; true,
                      'label' =&gt; 'Test2 Label',
                      'attr' =&gt; ['placeholder' =&gt; 'Test2 Place Holder']
                  ]
              )
              ;
  
          $builder-&gt;add(
              'plainPassword',
              RepeatedType::class,
              [
                  'type' =&gt; PasswordType::class,
                  'first_options' =&gt; [
                      'label' =&gt; 'oro.customer.customeruser.password.label',
                      'attr' =&gt; ['placeholder' =&gt; 'oro.customer.customeruser.placeholder.password']
                  ],
                  'second_options' =&gt; [
                      'label' =&gt; 'oro.customer.customeruser.password_confirmation.label',
                      'attr' =&gt; ['placeholder' =&gt; 'oro.customer.customeruser.placeholder.password_confirmation']
                  ],
                  'invalid_message' =&gt; 'oro.customer.message.password_mismatch',
                  'required' =&gt; true,
                  'validation_groups' =&gt; ['create']
              ]
          );
  
          $this-&gt;addBuilderListeners($builder);
      }
  
      /**
       * @return bool
       */
      private function isCompanyNameFieldEnabled()
      {
          return (bool) $this-&gt;configManager-&gt;get('oro_customer.company_name_field_enabled');
      }
  }
  </code></pre>
  
  <p>Oh, and i’ve also created success 2 column “test” and “test2” in table “oro_customer_user” using <strong>oro:migrations</strong>.<br></p>
  
  <p>Just ask when you need more file to check, thanks for helping :)</p>