I wrote an extension with wizardized forms utilizing civi's statemachine. If I call the wizard in js with CRM.loadForm() it closes when postprocessing the first form.

As far as I can see loadForm() appends snippet=json to the url and on next click, the statemachine's perform() calls the form's mainProcess which directly serves json.

So how can I achieve a modal wizard? Am I missing something?

Thanks in advance // nielo


I'm not saying that civi statemachine has been done a decade ago and that it shows, but most of us would rather do something else than trying to use it ;)

How familiar are you with angular? You would end up with a nicer and smoother interface, and angular is now part of the core and with lots of useful helpers to interface with the api.

Look what @totten has done for the new civimail interface on 4.6 for instance for inspiration and an example of modal interface.

He and robin did a session about angular at civicon london that you can watch online: https://london2014.civicrm.org/sessions/using-angularjs-enhance-user-experience

  • While figuring out, that the modal works if I tweak here and there (push another usercontext, tell js not to close on button click...) Angular just came to my mind a few minutes ago ;) Thanks for your tip, that's another five cents to my decision to rewrite the code...
    – nielo
    Apr 16 '15 at 12:11

CiviCRM's CRM.loadForm() does support multi-step forms. The trick is to inform the modal dialog that you want it to stay open and load the next page. Do so by adding this line to your form's postProcess function:

$this->ajaxResponse['status'] = 'redirect';
  • 1
    Thanks for your answer. I rewrote my stuff using angular since it is mostly separated from civi.
    – nielo
    Jun 10 '15 at 15:11
  • Afraid this doesn't work anymore: function custommodule_civicrm_postProcess($formName, &$form) { if ( $formName == 'CRM_Event_Form_ManageEvent_EventInfo') { $form->ajaxResponse['status'] = 'redirect'; } } Just does nothing.
    – yurg
    Feb 13 '18 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.