<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>

CC BY-SA 3.0
2014-07-01T22:21:51.270Z
2014-07-01T22:21:51.270Z
Bryan Redeagle
<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>

CC BY-SA 4.0
2020-11-20T08:37:55.923Z
Think I've found a solution

  Craft::$app->runAction('guestEntries/saveEntry');
  Craft::$app->runAction('formNotification/getForm);
mmorkt
CC BY-SA 4.0
2020-11-20T22:24:03.217Z
Want to edit your original post and add your comment as an official answer?
Brad Bell
CC BY-SA 4.0
2020-11-20T08:09:31.497Z
2020-11-20T08:09:31.497Z
mmorkt
<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>

CC BY-SA 3.0
2014-07-01T22:24:53.993Z
2014-07-01T22:24:53.993Z
Brandon Kelly
<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>

<plugins>
Multiple actions in a form?
# 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



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, 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.


---

### 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 event. I'm assuming that your formNotification plugin is a custom plugin that you wrote. Fortunately, events are easy:
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?  

---

