<p>You receive this error because <code>actionMyPluginActionController</code> expects a variable in it's parameters. You'll have to declare a default value </p>

<pre><code>public function actionMyPluginActionController($myVariable = null)
</code></pre>

<p>or you need to declare something in your <code>actionMyPluginActionControllerIndex</code></p>

<pre><code>public function actionMyPluginActionControllerIndex(){
    $myVariable = 'foo';
    $this-&gt;myPluginActionController($myVariable);
    return something;
}
</code></pre>

<p>Unless you deactivated error messages/warnings on global level (via web config, dev mode off or something else), there is no way this would work in Craft 2 by default </p>

CC BY-SA 3.0
2018-04-24T06:34:42.413Z
That did the job! Note:


`Unless you deactivated error messages/warnings on global level (via web config, dev mode off or something else), there is no way this would work in Craft 2 by default` 

These cases were neither set, it was indeed the variable declaration.
Kevon
CC BY-SA 3.0
2018-04-23T13:03:21.813Z
2018-04-23T13:03:21.813Z
Robin Schambach
<pre><code>public function actionMyPluginActionControllerIndex(){
    $this-&gt;myPluginActionController($myVariable);
    return something;
}

public function actionMyPluginActionController($myVariable)
{
    return something;
}
</code></pre>

<p>This is giving me the error:</p>

<p>{"error": "Missing required parameters": myVariable"}</p>

<p>I did exactly this with a craft 2 plugin, but somehow this doesn's seems to work in craft 3 anymore, what am i missing?</p>

<p>any help will be appreciated :)</p>

<plugin-development><craft3>
Posting from controller to controllers with parameter gives an error
# Posting from controller to controllers with parameter gives an error

(Asked by: username_0 on 2018-04-23)

public function actionMyPluginActionControllerIndex(){
    $this->myPluginActionController($myVariable);
    return something;
}

public function actionMyPluginActionController($myVariable)
{
    return something;
}

This is giving me the error:
{"error": "Missing required parameters": myVariable"}
I did exactly this with a craft 2 plugin, but somehow this doesn's seems to work in craft 3 anymore, what am i missing?
any help will be appreciated :)

**Tags:** plugin-development, craft3


---

## 1 answers

### Answer by username_1 on 2018-04-23. Score: 0 | Accepted answer

You receive this error because actionMyPluginActionController expects a variable in it's parameters. You'll have to declare a default value 
public function actionMyPluginActionController($myVariable = null)

or you need to declare something in your actionMyPluginActionControllerIndex
public function actionMyPluginActionControllerIndex(){
    $myVariable = 'foo';
    $this->myPluginActionController($myVariable);
    return something;
}

Unless you deactivated error messages/warnings on global level (via web config, dev mode off or something else), there is no way this would work in Craft 2 by default

> **Comments:**
> **username_0**: That did the job! Note:   `Unless you deactivated error messages/warnings on global level (via web config, dev mode off or something else), there is no way this would work in Craft 2 by default`   These cases were neither set, it was indeed the variable declaration.  

---

