ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

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

  • Creator
    Topic
  • #17555

    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
  • #17561

    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

    #17563

    Rodolfo
    Participant

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

    #17605

    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?

    #17608

    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.

    #17610

    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)

You must be logged in to reply to this topic.