ssossossosso

Forums

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

This topic contains 8 replies, has 4 voices, and was last updated by  musicthebee 1 year, 9 months ago.

  • Creator
    Topic
  • #15379

    maksold
    Participant

    I need to create comment with attachment on workflow transition. I solved problem, how to create comment on transition, but I can’t add attachment.

    Here is my code:

    When I run $ php app/console bro:workflow:definitions:load, I have error:

    What type of attribute should be comment_attachment?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #15812

    spolischook
    Participant

    But you need use UploadedFile (‘file’) form type and handle upload by your self.
    If you still need help, ask me, I show you how I implement it in my project.

    #16022

    spolischook
    Participant

    It’s not the best way, but it’s works.
    First you need custom form type for your transition that extended from WorkflowTransitionType. It will handle file upload by adding postSubmit listener.
    See my implementation https://git.io/vzYJm
    Next, use this form type for your transition by adding form_type attribute to transition

    In postSubmit convert UploadedFile to AttachmentFile or AttachmentImage according to your attribute type.

    After that you can do with attribute what you need.
    By the way, you can use setTarget method in extended entity to add relation, e.g.:

    #16023

    umatkid
    Participant

    spolischook,I have problem with it, I change to file form type, but can’t handle the uploadedFile.(got ERROR: Attribute must be an instance of “Oro\Bundle\AttachmentBundle\Entity\File”, but “Symfony\Component\HttpFoundation\File\UploadedFile” given”.
    Can you share your solutions with me and others 🙂
    It will be very helpful.

    #16024

    umatkid
    Participant

    spolischook, thank you for fast respond, try to use it.

    #16025

    spolischook
    Participant

    Don’t forget to load workflow definition after changes:

    Attribute must be an instance of “Oro\Bundle\AttachmentBundle\Entity\File”, but “Symfony\Component\HttpFoundation\File\UploadedFile” given” – is about that postSubmit not work correctly. Check that you reassign attribute in postSubmit

    #16026

    umatkid
    Participant

    The option “attachmentFileAttribute” does not exist. Known options are: “action”, “attr” etc.
    What problem with this one?

    #16027

    umatkid
    Participant

    Okay, I remove this option and put name of my field to the form type. And all work, so your method work perfect 🙂 Thank you a lot. Have a nice day 🙂

    #16591

    musicthebee
    Participant

    Thanks for this answer. I can add the attachment to the transition. However, When I try attach the attachment to the target entity, I get the following. Any ideas?

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

You must be logged in to reply to this topic.