OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions dynamic form in actions.yml operation definition

This topic contains 9 replies, has 3 voices, and was last updated by  adriwan_kenoby 5 years, 9 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
  • #34547

    adriwan_kenoby
    Participant

    Is it possible to render a dynamic form using actions.yml ?

    The first field “backupHost” rely to a ManyToMany association, The related entities are correctly display. Then I would like to have another field depend on the previous host selected.

    Dynamic form field are already difficult to handle in regular way, but in this case of yaml declaration I don’t know how to proceed or even if it is possible.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
    Replies
  • #34548

    Andrey Yatsenko
    Moderator

    Hi adriwan_kenoby,

    Actually the solution will be the same as with well known php forms.
    First you should use single Symfony form type for entire form that contains all the dynamic fields.

    Now it’s just a regular form.

    So a usual write all the dynamic logic at form type event listers.
    https://symfony.com/doc/2.8/form/dynamic_form_modification.html

    If you don’t have an entity or another model representing the whole form you can create DTO for that purpose and map form to it with “data_class” option.

    I didn’t find the example at ORO packages with actions.yml, but here it from the workflows for editing RFQ at OroCommerce, it’s very similar:
    https://github.com/oroinc/orocommerce/blob/1.6.1/src/Oro/Bundle/RFPBundle/Resources/config/oro/actions.yml#L55-L70
    The only difference, you’ll probably will have a DTO for it, for example of a form mapped to DTO you can check below links:
    DTO – https://github.com/oroinc/platform/blob/2.6.1/src/Oro/Bundle/ImapBundle/Form/Model/AccountTypeModel.php
    FormType for it – https://github.com/oroinc/platform/blob/2.6.1/src/Oro/Bundle/ImapBundle/Form/Type/ChoiceAccountType.php#L119

    #34549

    adriwan_kenoby
    Participant

    Hi Anyt,

    If I “use single Symfony form type for entire form that contains all the dynamic fields.”

    How then can I use it in actions.yml ?

    #34550

    Andrey Yatsenko
    Moderator
    #34551

    adriwan_kenoby
    Participant

    Thank you Anyt I will work on that. Still in need of comprehension of the Oro technologie stack chaplin + backbone + underscore…

    #34552

    Andrey Yatsenko
    Moderator

    You can check series of JS master class available in our youtube channel to understand it better


    #34553

    adriwan_kenoby
    Participant

    I come back to you because I try to do what I want based on the examples, but I can’t do it.

    To resume, I have an operation define in actions.yml

    the template associated with

    And the form type, here I don’t quite understand what I do in events…

    The JS component and view

    A function in a controller to render the form to be replaced

    and his template

    I am not sure if I need all this logic, maybe a JS view should be enough to satisfy my needs.
    And the problem is that their is still nothing dynamic in my form.

    Could you point me what I am doing wrong ?

    Thanks for your time and your help.

    #34554

    Viacheslav Bemza
    Participant

    Hello, adriwan_kenoby!

    Did you debug your code? Maybe you have some errors?
    First, check your ajax action, when you create a form, you need to pass the model as a second parameter, not the array.
    In addition, I suggest checking the correctness of loading js. Is the ajax action performed when the host changes?

    #34555

    adriwan_kenoby
    Participant

    The ajax actions is not performed. No error, nothing to help me to understand what is going wrong.

    #34558

    adriwan_kenoby
    Participant

    Finally achieved. A dynamic form displaying the content of a specific folder depending on selected server

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

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

Back to top