OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – How do I? Questions How to add a "beforeClose" or "close" callback in OroCRM Dialogs?

This topic contains 3 replies, has 2 voices, and was last updated by Hryhorii Hrebiniuk Hryhorii Hrebiniuk 1 year, 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
  • #37429


    jQuery UI dialogs has some callbacks like ‘close’ and ‘beforeClose’:


    My PHP render a dialog, like that below:

    How do I define a javascript callback, that shows a ‘alert()’ (for example), when dialog is closed?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #37446
    Hryhorii Hrebiniuk
    Hryhorii Hrebiniuk

    Hello @spyout98

    Since, close handler it’s a javascript function, we can not define it over widget declaration in twig, due to definition gets serialized into JSON.

    But you can extend existing dialog widget

    Declare it in requirejs configuration

    And change you action button definition



    Thanks, this solution worked here! I have one more doubt:

    Every dialog can be closed in two situations:

    * 1 – User cancels or close explicitly
    * 2 – User fill correctly the form and the dialog is automatically closed

    How to I execute a custom code when the user do the situation 2? Sometimes I can execute codes only when User cancel/close explicitly a dialog. Other times I want to execute some code when users fills the form and dialog is automatically closed.

    Hryhorii Hrebiniuk
    Hryhorii Hrebiniuk

    In the second case, user does not close dialog directly. Users submits form data and if it’s valid, server returns back the command to close the widget.

    So, it is too late of preventing dialog from closing at this stage. The content of dialog is disposed.

    See other methods of DialogWidget and AbstractWidget that you can overload and change logic to suite your needs.

    Probably methods that implement data submit.

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

The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.

You will be redirected to [title]. Would you like to continue?

Yes No