ssossossosso

Forums

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

This topic contains 6 replies, has 2 voices, and was last updated by ant-workaholic ant-workaholic 1 year, 11 months ago.

  • Creator
    Topic
  • #15084
    ant-workaholic
    ant-workaholic
    Participant

    Hello guys. I need your help. I have some entity which already have some attachments (this attachments needs for managers), but in a process in some transition customer should specify another attachments (“proofing image and proofing sheet”) which I will send to customer by email. If I will add this to main attachments I can’t to identify this files. I have added new fields to my entity:
    which I called proofing_sheet and proofing_image by this way:

    And then I tried to use this in my workflow:

    But in frontend it shows select in which I can choose all attachments which was uploaded for all entities. Please, give advise how I can do this or what I did wrong.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #15090
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    Hello.

    If you want to have only related attachments then you need to create custom form type – it should extend basic entity type and filter attachments by related entity (it can be extracted from parent form).

    If you wand to upload new file right from transition then you should use Symfony file form type and handle uploading yourself.

    #15103
    ant-workaholic
    ant-workaholic
    Participant

    I guess, that the first option will be the best for me. But how I can create new form_type to attribute? Where I can find example? Is this there: WorkflowBundle/Form/Type, Right?

    #15111
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    Well, there are two ways to do that – using customization of whole transition form type, or using customization of attachment selector form type.

    First way that will definitely work – create another form type for whole transition (child of WorkflowAttributesType) and set it via transiton form_type option. This form type should build query builder (or even list of choices) and pass it to attachment selector “entity” form type (that was automatically created based on your attribute) – so, this form type will render only related attachments.

    Second way is more straight forward, but a bit dirty. First you need to create a regular Symfony form type (probably, extended from “entity” type), here is example of transition definition. Then you need to get parent form on preSet event and somehow modify query builder (or list of choices) based on it. You can use option normalizers for that, the only question is how to pass parent form there (never tried to do that).

    #15114
    ant-workaholic
    ant-workaholic
    Participant

    Thank you, I will try to do this by the first option. As I understood, right, I should create new form type which should be inherited from ‘oro_workflow_attributes’ this I will specify in my getParent method. But, I am not sure that I understood how to “set it via transiton form_type option”.. Will try to fill gaps in my knowledge of Symfony forms and form_types.

    #15117
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    > which should be inherited from ‘oro_workflow_attributes’ this I will specify in my getParent method
    You should extend “oro_workflow_transition”, because it’s the form used in transition form.

    > I am not sure that I understood how to “set it via transiton form_type option”
    You see, by default all transitions rendered using “oro_workflow_transition” type, but you can change it in configuration of specific transition:

    So, after all in this custom form type you need to alter form options (“form_options” section) and customize attachment field options.

    #15213
    ant-workaholic
    ant-workaholic
    Participant

    Thank you for the advise. I successfully implemented this.

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

You must be logged in to reply to this topic.