OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions RESTful + (Many-To-One) + @ORM\Id on String Field

This topic contains 5 replies, has 1 voice, and was last updated by  Rodolfo 7 years, 11 months ago.

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

  • Creator
    Topic
  • #34131

    Rodolfo
    Participant

    Hello Oro Community,

    My problem today is making a RESTful Api working with custom entities and relations Many-To-One.

    1) This is what I have in Account entity. As you can see, I have @ORM\Id on my $originalEmail field.

    2) In Orders entity, as you can see, I created the relation Many-To-One (Multiple orders per Account and created the reference to my “original_email”.

    3) On my Orders Form Type, I have this inside my buildForm method:

    4) Inside my OrdersApiController I have my postAction() method using the Oro Abstraction layer to perform the insert.

    All RESTful methos for Acconts works fine. The problem is to use RESTful on Orders entity. Looks like
    there is something wrong with my “originalEmail” field.

    So I’m trying to insert orders using this structure:

    And the error is:

    …………,”originalEmail”:{“errors”:[“This value is not valid.”]}}}}………..

    Do you see something wrong or something that could be improved on my code?
    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #34132

    Rodolfo
    Participant

    Tried to implement my own postAction() with no luck. Looks like $form->valid() checks $request object and not the $entity object.

    I’m not sure yet if I’m getting this error because originalEmail is a string instead my custom account object. I’ll try to implement an event listener POST_SUBMIT in order to change originalValue from string to object before passing it to $form->isValid();

    Appreciate any help,
    Thanks

    #34133

    Rodolfo
    Participant

    The solution above worked. It was a cache problem.
    Thanks.

    #34134

    Rodolfo
    Participant

    I’m facing the same problem for the third entity on the chain. (OrderItems)

    Tried to create an EventListener to change the orderId integer “1234” to the object coming from MyOrders entity but still getting the same error.

    Does anybody knows anything to help?

    #34135

    Rodolfo
    Participant

    TransformationFailedException

    Unable to reverse value for property path “orderId”: The choice “199350” does not exist or is not unique

    Problem solved.. two orders with the same id was messing up things here.

    #34136

    Rodolfo
    Participant

    Looks like I’m still having problems.. I’m not sure why but looks like “translatable_entity” it’s not working for some reason.

Viewing 5 replies - 1 through 5 (of 5 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top