OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce How to Override Entity (Custom Customer Register Form)

This topic contains 1 reply, has 2 voices, and was last updated by Andrey Yatsenko Andrey Yatsenko 1 year, 4 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
  • #37620

    Hi, I’m trying to make a custom customer register form
    And to do so, i’ve to override this 2 file:


    So i’ve put this code in config/config.yml and it work as expected:

    But i also need to override entity as well, so it will render a new column to the customer register form.

    I’ve notice that FrontendCustomerUserRegistrationType have this code:

    And so CustomerBundle\Resources\config\services.yml have that too:

    So i’ve override it using config/config.yml:

    But it doesn’t work, it throw an error

    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.

    I think it make the override of FrontendCustomerUserRegistrationType go wrong and failed.

    Here is my overrided FrontendCustomerUserRegistrationType.php:

    Oh, and i’ve also created success 2 column “test” and “test2” in table “oro_customer_user” using oro:migrations.

    Just ask when you need more file to check, thanks for helping :)

Viewing 1 replies (of 1 total)
  • Author
  • #37670
    Andrey Yatsenko
    Andrey Yatsenko

    To extend the form it’s easier to use form type extensions instead of extending the form type and overriding all the places where the original form type was used.

    Please check the documentation on it:

    P.S. Symfony forms extending works in a different way, you should not use PHP extends functionality, but instead, use getParent method. But I highly recommend you to use form type extensions instead

Viewing 1 replies (of 1 total)

The forum ‘OroCommerce’ is closed to new topics and replies.

You will be redirected to [title]. Would you like to continue?

Yes No