Answers.Body: <p>You can't run multiple actions in one request. What you're looking to do is trigger your notification action after the <a href="http://buildwithcraft.com/docs/plugins/events-reference#entries-onSaveEntry" rel="nofollow"><code>entries.saveEntry</code></a> event. I'm assuming that your <code>formNotification</code> plugin is a custom plugin that you wrote. Fortunately, <a href="http://buildwithcraft.com/docs/plugins/hooks-and-events#listening-for-events" rel="nofollow">events are easy</a>:</p>
  
  <pre><code>craft()-&gt;on('entries.saveEntry', function(Event $event) {
      // Your notification code here.
  });
  </code></pre>
  
  <p>The best place to add this event listener is in your plugin's <code>init</code> function. This is located in the main plugin file.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-01T22:21:51.270Z
Answers.LastActivityDate: 2014-07-01T22:21:51.270Z
Answers.UserDisplayName: Bryan Redeagle
Answers.Body: <p>How would you write this in Craft CMS 3 / Yii2?</p>
  <pre><code>class MyPluginController
  {
      public function actionSaveEntryAndSendNotification()
      {
          // Save the entry
          craft()-&gt;runController('guestEntries/saveEntry');
  
          // Send the notification
          craft()-&gt;runController('formNotification/getForm');
      }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-20T08:37:55.923Z
Answers.Text: Think I've found a solution
  
    Craft::$app->runAction('guestEntries/saveEntry');
    Craft::$app->runAction('formNotification/getForm);
Answers.UserDisplayName: mmorkt
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-20T22:24:03.217Z
Answers.Text: Want to edit your original post and add your comment as an official answer?
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-20T08:09:31.497Z
Answers.LastActivityDate: 2020-11-20T08:09:31.497Z
Answers.UserDisplayName: mmorkt
Answers.Body: <p>It’s not possible for a form to simultaneously invoke two controller actions.</p>
  
  <p>You would need to write a plugin that provides its own <a href="http://buildwithcraft.com/docs/plugins/controllers">controller</a>, which in turn could be used to invoke the other controller actions.</p>
  
  <pre><code>class MyPluginController
  {
      public function actionSaveEntryAndSendNotification()
      {
          // Save the entry
          craft()-&gt;runController('guestEntries/saveEntry');
  
          // Send the notification
          craft()-&gt;runController('formNotification/getForm');
      }
  }
  </code></pre>
  
  <p>If "FormNotificationController" is already your own custom plugin, then it might make more sense to just call <code>craft()-&gt;runController('guestEntries/saveEntry');</code> from the top of <code>actionGetForm()</code>. Or just save the entry yourself from the controller action – the Guest Entries plugin is really pretty simple; most of the heavy lifting is provided by the <a href="http://buildwithcraft.com/docs/apis/entriesservice#saveEntry">EntriesService - saveEntry() API</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-01T22:24:53.993Z
Answers.LastActivityDate: 2014-07-01T22:24:53.993Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I have two plugins that I want to use in a single form.  One is a Guest Entry plugin to save the data submitted in the form, and the other is a Plugin that sends an email notification when the form is submitted.</p>
  
  <p>I want to use both of these in the same form but I'm not sure how.  If I have</p>
  
  <pre><code>&lt;input type="hidden" name="action" value="guestEntries/saveEntry"&gt;
  &lt;input type="hidden" name="action" value="formNotification/getForm"&gt;
  </code></pre>
  
  <p>It won't work since both have the name "action"
  and I can't change the name or the functions never get called.</p>
  
  <p>What can I do to make both of them work?</p>
  
Tags: <plugins>
Title: Multiple actions in a form?
ThreadText: # Multiple actions in a form?
  
  (Asked by: username_0 on 2014-07-01)
  
  I have two plugins that I want to use in a single form. One is a Guest Entry plugin to save the data submitted in the form, and the other is a Plugin that sends an email notification when the form is submitted.
  
  I want to use both of these in the same form but I'm not sure how. If I have
  
  ```
  <input type="hidden" name="action" value="guestEntries/saveEntry">
  <input type="hidden" name="action" value="formNotification/getForm">
  
  ```
  
  It won't work since both have the name "action"
  and I can't change the name or the functions never get called.
  
  What can I do to make both of them work?
  
  **Tags:** plugins
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_4 on 2014-07-01. Score: 7 | Accepted answer
  
  It’s not possible for a form to simultaneously invoke two controller actions.
  
  You would need to write a plugin that provides its own [controller](http://buildwithcraft.com/docs/plugins/controllers), which in turn could be used to invoke the other controller actions.
  
  ```
  class MyPluginController
  {
      public function actionSaveEntryAndSendNotification()
      {
          // Save the entry
          craft()->runController('guestEntries/saveEntry');
  
          // Send the notification
          craft()->runController('formNotification/getForm');
      }
  }
  
  ```
  
  If "FormNotificationController" is already your own custom plugin, then it might make more sense to just call `craft()->runController('guestEntries/saveEntry');` from the top of `actionGetForm()`. Or just save the entry yourself from the controller action – the Guest Entries plugin is really pretty simple; most of the heavy lifting is provided by the [EntriesService - saveEntry() API](http://buildwithcraft.com/docs/apis/entriesservice#saveEntry).
  
  
  ---
  
  ### Answer by username_1 on 2014-07-01. Score: 3
  
  You can't run multiple actions in one request. What you're looking to do is trigger your notification action after the [`entries.saveEntry`](http://buildwithcraft.com/docs/plugins/events-reference#entries-onSaveEntry) event. I'm assuming that your `formNotification` plugin is a custom plugin that you wrote. Fortunately, [events are easy](http://buildwithcraft.com/docs/plugins/hooks-and-events#listening-for-events):
  
  ```
  craft()->on('entries.saveEntry', function(Event $event) {
      // Your notification code here.
  });
  
  ```
  
  The best place to add this event listener is in your plugin's `init` function. This is located in the main plugin file.
  
  
  ---
  
  ### Answer by username_2 on 2020-11-20. Score: 0
  
  How would you write this in Craft CMS 3 / Yii2?
  
  ```
  class MyPluginController
  {
      public function actionSaveEntryAndSendNotification()
      {
          // Save the entry
          craft()->runController('guestEntries/saveEntry');
  
          // Send the notification
          craft()->runController('formNotification/getForm');
      }
  }
  
  ```
  
  > **Comments:**
  > **username_2**: Think I've found a solution    Craft::$app->runAction('guestEntries/saveEntry');   Craft::$app->runAction('formNotification/getForm);  
  > **username_3**: Want to edit your original post and add your comment as an official answer?  
  
  ---
  
  