OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions Use EntityType in FormType, reused by JSON API endpoint

This topic contains 1 reply, has 2 voices, and was last updated by  Mike Kudelya 7 years ago.

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

  • Creator
    Topic
  • #36451

    mechovic.pavel
    Participant

    Hello,

    I have created a form type, which looks something like that:

    Such a form without ‘client’ element (which is of Symfony\Bridge\Doctrine\Form\Type\EntityType) works fine both in browser and via API. But I cannot use EntityType via API, because, I as understand, it is not registered as API form type (we want to use JSON API, provided by OroApiBundle).
    Later I have found that ORO platform has its own Oro\Bundle\ApiBundle\Form\Type\EntityType, which I can use via API (but it does not work from browser) if I configure it like this:

    I would like to reuse my form type to create new entities both in browser and in external apps via API. So far, I am thinking about registering this form as two services and use correct entity type, based on the service type:

    This solution would work for us, but I just wanted to get some feedback from ORO team if this is good practice, or if there is a better way to reuse custom form type in API.

    Thank you.

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #36452

    Mike Kudelya
    Participant

    Hi

    As a rule, you should separate two forms into two classes, because it is highly probable that changing the form can break either the API or the UI.

Viewing 1 replies (of 1 total)

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

Back to top