Answers.Body: <p>My solution was to load the template directly rather than routing to the controller first.  Essentially, in my <code>registerSiteRoutes()</code> function I replaced this:</p>
  
  <pre><code>"payment" =&gt; ['action' =&gt; 'someController/doPayment']
  </code></pre>
  
  <p>with</p>
  
  <pre><code>"payment" =&gt; 'templateDir/core/payment'
  </code></pre>
  
  <p>I didn't even realize you could do this in <code>registerSiteRoutes()</code>!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-31T19:22:28.653Z
Answers.LastActivityDate: 2017-01-31T19:22:28.653Z
Answers.UserDisplayName: Billy Pilgrim
Body: <p>everybody!</p>
  
  <p><code>setRouteVariables()</code> doesn't appear to be working for me.  If I boil my controller function down to just this:</p>
  
  <pre><code>public function actionSubmitForm() {
      craft()-&gt;urlManager-&gt;setRouteVariables([
          'foo' =&gt; 'bar'
      ]);
  }
  </code></pre>
  
  <p>and my <code>&lt;form method="post" action="" accept-charset="UTF-8"&gt;</code> contains the following (among other inputs):</p>
  
  <pre><code>&lt;input type="hidden" name="action" value="directoryForms/submitForm"&gt;
  </code></pre>
  
  <p>it hits the correct endpoint and then reloads the appropriate template, but it doesn't give me access to the <code>{{ foo }}</code> variable in that template.  It just tells me <code>Variable "foo" does not exist</code>.  I know it's hitting the right controller endpoint because if I <code>die()</code> there it dies as expected.</p>
  
  <p>Any thoughts?  I've really boiled this one down as far as I can.  I must be missing something obvious.  Thanks!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-31T05:14:14.107Z
Comments.Text: Just a guess, but something else (another plugin?) is redirecting/interfering with the request of the request and not letting it continue as you're expecting?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-31T13:36:27.860Z
Comments.Text: Ah, I do have custom routes set for this plugin via registerSiteRoutes()!  How does that change how I proceed?  I'd like to pass these variables back through that custom site route.  (My full use case is filling in bad user input on validation failure)
Comments.UserDisplayName: Billy Pilgrim
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-31T14:16:53.913Z
Comments.Text: Alrighty, I've got it now.  Thanks for the push in the right directory, Brad.  I ended up routing directly to a template rather than an action which loads a template.  I didn't even realize that could be done!
Comments.UserDisplayName: Billy Pilgrim
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-31T18:22:43.037Z
Comments.Text: Would you mind adding what worked for you as an official answer in case it ends up helping someone else in the future?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-31T19:19:13.530Z
Comments.Text: Of course!  Thanks for all you do in the community, Brad.
Comments.UserDisplayName: Billy Pilgrim
Tags: <templating><routes><variable>
Title: craft()->urlManager->setRouteVariables() loads the correct template but does not pass in the variables
ThreadText: # craft()->urlManager->setRouteVariables() loads the correct template but does not pass in the variables
  
  (Asked by: username_0 on 2017-01-30)
  
  everybody!
  
  `setRouteVariables()` doesn't appear to be working for me. If I boil my controller function down to just this:
  
  ```
  public function actionSubmitForm() {
      craft()->urlManager->setRouteVariables([
          'foo' => 'bar'
      ]);
  }
  
  ```
  
  and my `<form method="post" action="" accept-charset="UTF-8">` contains the following (among other inputs):
  
  ```
  <input type="hidden" name="action" value="directoryForms/submitForm">
  
  ```
  
  it hits the correct endpoint and then reloads the appropriate template, but it doesn't give me access to the `{{ foo }}` variable in that template. It just tells me `Variable "foo" does not exist`. I know it's hitting the right controller endpoint because if I `die()` there it dies as expected.
  
  Any thoughts? I've really boiled this one down as far as I can. I must be missing something obvious. Thanks!
  
  **Tags:** templating, routes, variable
  
  > **Comments:**
  > **username_1**: Just a guess, but something else (another plugin?) is redirecting/interfering with the request of the request and not letting it continue as you're expecting?  
  > **username_0**: Ah, I do have custom routes set for this plugin via registerSiteRoutes()!  How does that change how I proceed?  I'd like to pass these variables back through that custom site route.  (My full use case is filling in bad user input on validation failure)  
  > **username_0**: Alrighty, I've got it now.  Thanks for the push in the right directory, username_1.  I ended up routing directly to a template rather than an action which loads a template.  I didn't even realize that could be done!  
  > **username_1**: Would you mind adding what worked for you as an official answer in case it ends up helping someone else in the future?  
  > **username_0**: Of course!  Thanks for all you do in the community, username_1.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-01-31. Score: 1 | Accepted answer
  
  My solution was to load the template directly rather than routing to the controller first. Essentially, in my `registerSiteRoutes()` function I replaced this:
  
  ```
  "payment" => ['action' => 'someController/doPayment']
  
  ```
  
  with
  
  ```
  "payment" => 'templateDir/core/payment'
  
  ```
  
  I didn't even realize you could do this in `registerSiteRoutes()`!
  
  
  ---
  
  