Answers.Body: <p>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 ;)</p>
  
  <p>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.</p>
  
  <p>Look what @totten has done for the new civimail interface on 4.6 for instance for inspiration and an example of modal interface.</p>
  
  <p>He and robin did a session about angular at civicon london that you can watch online:
  <a href="https://london2014.civicrm.org/sessions/using-angularjs-enhance-user-experience" rel="nofollow">https://london2014.civicrm.org/sessions/using-angularjs-enhance-user-experience</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-16T12:11:03.073Z
Answers.Text: 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...
Answers.UserDisplayName: nielo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-16T12:06:55.027Z
Answers.LastActivityDate: 2015-04-16T12:06:55.027Z
Answers.UserDisplayName: Xavier
Answers.Body: <p>CiviCRM's <code>CRM.loadForm()</code> 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:</p>
  
  <pre><code>$this-&gt;ajaxResponse['status'] = 'redirect';
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-13T19:11:31.233Z
Answers.Text: 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.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-10T15:11:51.640Z
Answers.Text: Thanks for your answer. I rewrote my stuff using angular since it is mostly separated from civi.
Answers.UserDisplayName: nielo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-09T13:49:59.183Z
Answers.LastActivityDate: 2015-06-09T13:49:59.183Z
Answers.UserDisplayName: Coleman
Body: <p>I wrote an extension with wizardized forms utilizing civi's statemachine. If I call the wizard in js with <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Ajax+Pages+and+Forms#AjaxPagesandForms-CRM.loadForm%28url,options%29" rel="nofollow"><code>CRM.loadForm()</code></a> it closes when postprocessing the first form. </p>
  
  <p>As far as I can see <code>loadForm()</code> appends <code>snippet=json</code> to the url and on next click, the statemachine's <code>perform()</code> calls the form's <code>mainProcess</code> which directly serves json.</p>
  
  <p>So how can I achieve a modal wizard? Am I missing something?</p>
  
  <p>Thanks in advance // nielo</p>
  
Tags: <extension>
Title: How to create a statemachine/wizard in a modal/popup?
ThreadText: # How to create a statemachine/wizard in a modal/popup?
  
  (Asked by: username_0 on 2015-04-16)
  
  I wrote an extension with wizardized forms utilizing civi's statemachine. If I call the wizard in js with [`CRM.loadForm()`](http://wiki.civicrm.org/confluence/display/CRMDOC/Ajax+Pages+and+Forms#AjaxPagesandForms-CRM.loadForm%28url,options%29) 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 // username_0
  
  **Tags:** extension
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-04-16. Score: 2 | Accepted answer
  
  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>
  
  > **Comments:**
  > **username_0**: 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...  
  
  ---
  
  ### Answer by username_2 on 2015-06-09. Score: 2
  
  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';
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for your answer. I rewrote my stuff using angular since it is mostly separated from civi.  
  > **username_3**: 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.  
  
  ---
  
  