title: CakePHP Login Layout
body: <p>I created a login view for my <code>Employee controller</code>, but when the login view renders, it shows up as a plain white page (not the layout from my default.ctp).</p>
  
  <p>I tried calling <code>$this-&gt;layout = 'default';</code> from the login action,<br>
  but it sounds like that code will not execute until after the view has posted.</p>
  
  <p><strong>controllers/employee_controller.php</strong></p>
  
  <pre><code>function login() {
      $this-&gt;layout = 'default';
  }
  </code></pre>
  
  <p><strong>views/layouts/default.ctp</strong></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
          &lt;title&gt;&lt;?php echo $title_for_layout; ?&gt;&lt;/title&gt;
          &lt;link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /&gt;
          &lt;link rel="stylesheet" type="text/css" href='&lt;?php echo "css".DS."cake.generic.css" ?&gt;' /&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;div id="parentDiv"&gt;
          &lt;div id="menu"&gt;
              &lt;div id="messages"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div id="header"&gt;
              &lt;?= $this-&gt;element('search'); ?&gt;
          &lt;/div&gt;
          &lt;div id="content"&gt;
              &lt;?php echo $content_for_layout; ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>views/employees/login.ctp</strong></p>
  
  <pre><code>&lt;?= debug($this); ?&gt;
  &lt;div&gt;
      &lt;div style="border: black solid 1px"&gt;
          &lt;?php
          /*
           * To change this template, choose Tools | Templates
           * and open the template in the editor.
           */
          echo $this-&gt;Form-&gt;create('Employee', array('url' =&gt; array('controller' =&gt; 'employees', 'action' =&gt; 'login')));
          echo $this-&gt;Form-&gt;input('username');
          echo $this-&gt;Form-&gt;input('password');
          echo $this-&gt;Form-&gt;submit('Login');
          echo $this-&gt;Form-&gt;end();
          ?&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>