title: AJAX autofill Cakephp 3 form
body: <p>I am trying to auto fill defaults on my invoices form with customer data based off the customer selected in the drop down. Once the customer is selected in this drop down in the photo below I want it to auto fill the addresses from the data found in the customer table in the next photo below also. <a href="https://i.stack.imgur.com/1Zdjw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Zdjw.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/jT8RI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jT8RI.png" alt="enter image description here"></a></p>
  
  <p>So far this is my invoices add.ctp script to try fetch the data. Currently with this script I can fetch  the customer id that was selected to use in a sql query and also set data in the forms inputs</p>
  
  <pre><code>&lt;script&gt;
  
              document.getElementById('customers').addEventListener('change',function(){
                 alert(this.value);
              $('#customers').click(function(){
                  $.ajax({
                      type: "POST",
                      url: '&lt;?php echo Router::url(array('controller' =&gt; 'Customers', 'action' =&gt; 'fill')); ?&gt;',
                      success: function(data){
                          alert(data);
                      }
                  });
              });
  
              document.getElementById('name').value = "test"
              document.getElementById('invoice_to_address').value = "test"
  
              });
  
          &lt;/script&gt;
  </code></pre>
  
  <p>This is my fill function in my CustomersController. This is where I am going wrong I think my query is probably completely wrong and it's not searching for the right thing and returning it incorrectly and probably not even using the customer ID from the form. Currently it just returns no data but also has no errors and an empty alert box comes up due to the script in the view.</p>
  
  <pre><code> public function fill()
  {
      $layout = 'ajax'; // you need to have a no html page, only the data.
      $this-&gt;autoRender = false; // no need to render the page, just plain data.
      $data = array();
  
      $id = $this-&gt;request-&gt;data();
      $query = $this-&gt;Customers-&gt;find()
      -&gt;where([
      'id' =&gt; $id]);
  
  $this-&gt;set(array(
      'id' =&gt; $query,
      '_serialize' =&gt; 'id'
      ));    
  
  
  }
  </code></pre>
  
  <p>UPDATE </p>
  
  <p>My full Invoices add.ctp</p>
  
  <pre><code>    &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&gt;
  &lt;script src="http://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
  &lt;script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"&gt;&lt;/script&gt;
  &lt;?php echo $this-&gt;Html-&gt;script('jquery.chained'); ?&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $("#contacts").chained("#customers");
      });
  &lt;/script&gt;
  &lt;?php use Cake\Routing\Router; ?&gt;
  &lt;?php
  /**
    * @var \App\View\AppView $this
    */
  ?&gt;
  &lt;nav class="large-3 medium-4 columns" id="actions-sidebar"&gt;
      &lt;ul class="side-nav"&gt;
          &lt;li class="heading"&gt;&lt;?= __('Actions') ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Invoices'), ['action' =&gt; 'index']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Customers'), ['controller' =&gt; 'Customers', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Customer'), ['controller' =&gt; 'Customers', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Customer Contacts'), ['controller' =&gt; 'CustomerContacts', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Customer Contact'), ['controller' =&gt; 'CustomerContacts', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Aircraft Registrations'), ['controller' =&gt; 'AircraftRegistrations', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Aircraft Registration'), ['controller' =&gt; 'AircraftRegistrations', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Shipping Companies'), ['controller' =&gt; 'ShippingCompanies', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Shipping Company'), ['controller' =&gt; 'ShippingCompanies', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Job Types'), ['controller' =&gt; 'JobTypes', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Job Type'), ['controller' =&gt; 'JobTypes', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Currencies'), ['controller' =&gt; 'Currencies', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Currency'), ['controller' =&gt; 'Currencies', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/nav&gt;
  &lt;div class="invoices form large-9 medium-8 columns content"&gt;
      &lt;?= $this-&gt;Form-&gt;create($invoice) ?&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;&lt;?= __('Add Invoice') ?&gt;&lt;/legend&gt;
          &lt;?php
              echo $this-&gt;Form-&gt;input('start_date', ['empty' =&gt; false]);
              echo $this-&gt;Form-&gt;input('close_date', ['empty' =&gt; true]);
              echo $this-&gt;Form-&gt;input('customer_id', ['options' =&gt; $customers, 'empty' =&gt; true,'id'=&gt;'customers']);
              echo $this-&gt;Form-&gt;input('name', ['type' =&gt; 'text', 'id'=&gt;'name']);
              echo $this-&gt;Form-&gt;input('invoice_to_address', ['type' =&gt; 'text', 'id'=&gt;'invoice_to_address']);
              echo $this-&gt;Form-&gt;input('ship_to_address');
              echo $this-&gt;Form-&gt;input('customer_contact_id', ['options' =&gt; $customerContacts, 'empty' =&gt; true,'id'=&gt;'contacts']);
              echo $this-&gt;Form-&gt;input('currency_id', ['options' =&gt; $currencies, 'default'=&gt; 1, 'id'=&gt;'currencies']);
          ?&gt;
  
      &lt;/fieldset&gt;
      &lt;?= $this-&gt;Form-&gt;button(__('Submit')) ?&gt;
      &lt;?= $this-&gt;Form-&gt;end() ?&gt;
      &lt;?= $this-&gt;Form-&gt;create(Null, ['type' =&gt; 'POST']) ?&gt;
      &lt;?= $this-&gt;Form-&gt;end() ?&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
          jQuery('#name').autocomplete({source:'&lt;?php echo Router::url(array('controller' =&gt; 'Customers', 'action' =&gt; 'search')); ?&gt;'
          });
  &lt;/script&gt;
  
  &lt;script&gt;
      document.getElementById('customers').addEventListener('change',function(){
         var id = this.value;
         alert(id);
          var csrfToken = $('[name=_csrfToken]').val();
          $.ajax({
              type: "POST",
              url: '&lt;?php echo Router::url(array("controller" =&gt; "Customers", "action" =&gt; "fill")); ?&gt;',
              data: {'id' : id},
              beforeSend: function(xhr){
                 xhr.setRequestHeader('X-CSRF-Token', csrfToken);
              },
              success: function(data){
                  alert(data);
                  data = JSON.parse(data);
                  alert("id: " + data.id);
              }
          });
      document.getElementById('name').value = "test"
      document.getElementById('invoice_to_address').value = "test"
      document.getElementById('currencies').value = 3;
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>and the controller fill function</p>
  
  <pre><code>public function fill(){
      $layout = 'ajax'; // you need to have a no html page, only the data.
      $this-&gt;autoRender = false; // no need to render the page, just plain data.
      if ($this-&gt;request-&gt;is('ajax')) {
          $id = $this-&gt;request-&gt;data['id'];
          $query = $this-&gt;Customers-&gt;find()
          -&gt;where([
             'id' =&gt; $id
          ])-&gt;first();
          echo json_encode($query);  
      }  
  }
  </code></pre>
  
  <p>What happens when ($this->request->is('ajax')) is there. There's no response or preview.
  <a href="https://i.stack.imgur.com/ZbbNq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZbbNq.png" alt="enter image description here"></a></p>
  
  <p>When if ($this->request->is('ajax')) is removed.
  <a href="https://i.stack.imgur.com/qBaQE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qBaQE.png" alt="enter image description here"></a></p>
  
  <p>Here is the full error message</p>
  
  <pre><code>{"id":0,"name":"Sky Works","country_id":1,"city_id":6,"address":"Sky works address in the customers table","postal_address":"Sky works shippng address in the customers table","phone":"","email":"","payment_terms_id":1,"stop_credit":false,"gst_percentage":null,"currency_id":"2","account_closed":false,"invoice_email":"","customer_notes":""}&lt;pre class="cake-error"&gt;&lt;a href="javascript:void(0);" onclick="document.getElementById('cakeErr5a1140bb8332d-trace').style.display = (document.getElementById('cakeErr5a1140bb8332d-trace').style.display == 'none' ? '' : 'none');"&gt;&lt;b&gt;Warning&lt;/b&gt; (512)&lt;/a&gt;: Unable to emit headers. Headers sent in file=/home/southpac/southpacificavionics.com/team/src/Controller/CustomersController.php line=179 [&lt;b&gt;CORE/src/Http/ResponseEmitter.php&lt;/b&gt;, line &lt;b&gt;48&lt;/b&gt;]&lt;div id="cakeErr5a1140bb8332d-trace" class="cake-stack-trace" style="display: none;"&gt;&lt;a href="javascript:void(0);" onclick="document.getElementById('cakeErr5a1140bb8332d-code').style.display = (document.getElementById('cakeErr5a1140bb8332d-code').style.display == 'none' ? '' : 'none')"&gt;Code&lt;/a&gt; &lt;a href="javascript:void(0);" onclick="document.getElementById('cakeErr5a1140bb8332d-context').style.display = (document.getElementById('cakeErr5a1140bb8332d-context').style.display == 'none' ? '' : 'none')"&gt;Context&lt;/a&gt;&lt;pre id="cakeErr5a1140bb8332d-code" class="cake-code-dump" style="display: none;"&gt;&lt;code&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000BB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$message&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #DD0000"&gt;"Unable&amp;nbsp;to&amp;nbsp;emit&amp;nbsp;headers.&amp;nbsp;Headers&amp;nbsp;sent&amp;nbsp;in&amp;nbsp;file=&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$file&lt;/span&gt;&lt;span style="color: #DD0000"&gt;&amp;nbsp;line=&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$line&lt;/span&gt;&lt;span style="color: #DD0000"&gt;"&lt;/span&gt;&lt;span style="color: #007700"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;
  &lt;span class="code-highlight"&gt;&lt;code&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000BB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;if&amp;nbsp;(&lt;/span&gt;&lt;span style="color: #0000BB"&gt;Configure&lt;/span&gt;&lt;span style="color: #007700"&gt;::&lt;/span&gt;&lt;span style="color: #0000BB"&gt;read&lt;/span&gt;&lt;span style="color: #007700"&gt;(&lt;/span&gt;&lt;span style="color: #DD0000"&gt;'debug'&lt;/span&gt;&lt;span style="color: #007700"&gt;))&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;
  &lt;code&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000BB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;trigger_error&lt;/span&gt;&lt;span style="color: #007700"&gt;(&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$message&lt;/span&gt;&lt;span style="color: #007700"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #0000BB"&gt;E_USER_WARNING&lt;/span&gt;&lt;span style="color: #007700"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre id="cakeErr5a1140bb8332d-context" class="cake-context" style="display: none;"&gt;$response = object(Zend\Diactoros\Response) {
      [protected] headers =&amp;gt; [
          &amp;#039;Content-Type&amp;#039; =&amp;gt; [
              [maximum depth reached]
          ]
      ]
      [protected] headerNames =&amp;gt; [
          &amp;#039;content-type&amp;#039; =&amp;gt; &amp;#039;Content-Type&amp;#039;
      ]
      [private] phrases =&amp;gt; [
          (int) 100 =&amp;gt; &amp;#039;Continue&amp;#039;,
          (int) 101 =&amp;gt; &amp;#039;Switching Protocols&amp;#039;,
          (int) 102 =&amp;gt; &amp;#039;Processing&amp;#039;,
          (int) 200 =&amp;gt; &amp;#039;OK&amp;#039;,
          (int) 201 =&amp;gt; &amp;#039;Created&amp;#039;,
          (int) 202 =&amp;gt; &amp;#039;Accepted&amp;#039;,
          (int) 203 =&amp;gt; &amp;#039;Non-Authoritative Information&amp;#039;,
          (int) 204 =&amp;gt; &amp;#039;No Content&amp;#039;,
          (int) 205 =&amp;gt; &amp;#039;Reset Content&amp;#039;,
          (int) 206 =&amp;gt; &amp;#039;Partial Content&amp;#039;,
          (int) 207 =&amp;gt; &amp;#039;Multi-status&amp;#039;,
          (int) 208 =&amp;gt; &amp;#039;Already Reported&amp;#039;,
          (int) 226 =&amp;gt; &amp;#039;IM used&amp;#039;,
          (int) 300 =&amp;gt; &amp;#039;Multiple Choices&amp;#039;,
          (int) 301 =&amp;gt; &amp;#039;Moved Permanently&amp;#039;,
          (int) 302 =&amp;gt; &amp;#039;Found&amp;#039;,
          (int) 303 =&amp;gt; &amp;#039;See Other&amp;#039;,
          (int) 304 =&amp;gt; &amp;#039;Not Modified&amp;#039;,
          (int) 305 =&amp;gt; &amp;#039;Use Proxy&amp;#039;,
          (int) 306 =&amp;gt; &amp;#039;Switch Proxy&amp;#039;,
          (int) 307 =&amp;gt; &amp;#039;Temporary Redirect&amp;#039;,
          (int) 308 =&amp;gt; &amp;#039;Permanent Redirect&amp;#039;,
          (int) 400 =&amp;gt; &amp;#039;Bad Request&amp;#039;,
          (int) 401 =&amp;gt; &amp;#039;Unauthorized&amp;#039;,
          (int) 402 =&amp;gt; &amp;#039;Payment Required&amp;#039;,
          (int) 403 =&amp;gt; &amp;#039;Forbidden&amp;#039;,
          (int) 404 =&amp;gt; &amp;#039;Not Found&amp;#039;,
          (int) 405 =&amp;gt; &amp;#039;Method Not Allowed&amp;#039;,
          (int) 406 =&amp;gt; &amp;#039;Not Acceptable&amp;#039;,
          (int) 407 =&amp;gt; &amp;#039;Proxy Authentication Required&amp;#039;,
          (int) 408 =&amp;gt; &amp;#039;Request Time-out&amp;#039;,
          (int) 409 =&amp;gt; &amp;#039;Conflict&amp;#039;,
          (int) 410 =&amp;gt; &amp;#039;Gone&amp;#039;,
          (int) 411 =&amp;gt; &amp;#039;Length Required&amp;#039;,
          (int) 412 =&amp;gt; &amp;#039;Precondition Failed&amp;#039;,
          (int) 413 =&amp;gt; &amp;#039;Request Entity Too Large&amp;#039;,
          (int) 414 =&amp;gt; &amp;#039;Request-URI Too Large&amp;#039;,
          (int) 415 =&amp;gt; &amp;#039;Unsupported Media Type&amp;#039;,
          (int) 416 =&amp;gt; &amp;#039;Requested range not satisfiable&amp;#039;,
          (int) 417 =&amp;gt; &amp;#039;Expectation Failed&amp;#039;,
          (int) 418 =&amp;gt; &amp;#039;I&amp;#039;m a teapot&amp;#039;,
          (int) 421 =&amp;gt; &amp;#039;Misdirected Request&amp;#039;,
          (int) 422 =&amp;gt; &amp;#039;Unprocessable Entity&amp;#039;,
          (int) 423 =&amp;gt; &amp;#039;Locked&amp;#039;,
          (int) 424 =&amp;gt; &amp;#039;Failed Dependency&amp;#039;,
          (int) 425 =&amp;gt; &amp;#039;Unordered Collection&amp;#039;,
          (int) 426 =&amp;gt; &amp;#039;Upgrade Required&amp;#039;,
          (int) 428 =&amp;gt; &amp;#039;Precondition Required&amp;#039;,
          (int) 429 =&amp;gt; &amp;#039;Too Many Requests&amp;#039;,
          (int) 431 =&amp;gt; &amp;#039;Request Header Fields Too Large&amp;#039;,
          (int) 444 =&amp;gt; &amp;#039;Connection Closed Without Response&amp;#039;,
          (int) 451 =&amp;gt; &amp;#039;Unavailable For Legal Reasons&amp;#039;,
          (int) 499 =&amp;gt; &amp;#039;Client Closed Request&amp;#039;,
          (int) 500 =&amp;gt; &amp;#039;Internal Server Error&amp;#039;,
          (int) 501 =&amp;gt; &amp;#039;Not Implemented&amp;#039;,
          (int) 502 =&amp;gt; &amp;#039;Bad Gateway&amp;#039;,
          (int) 503 =&amp;gt; &amp;#039;Service Unavailable&amp;#039;,
          (int) 504 =&amp;gt; &amp;#039;Gateway Time-out&amp;#039;,
          (int) 505 =&amp;gt; &amp;#039;HTTP Version not supported&amp;#039;,
          (int) 506 =&amp;gt; &amp;#039;Variant Also Negotiates&amp;#039;,
          (int) 507 =&amp;gt; &amp;#039;Insufficient Storage&amp;#039;,
          (int) 508 =&amp;gt; &amp;#039;Loop Detected&amp;#039;,
          (int) 510 =&amp;gt; &amp;#039;Not Extended&amp;#039;,
          (int) 511 =&amp;gt; &amp;#039;Network Authentication Required&amp;#039;,
          (int) 599 =&amp;gt; &amp;#039;Network Connect Timeout Error&amp;#039;
      ]
      [private] reasonPhrase =&amp;gt; &amp;#039;&amp;#039;
      [private] statusCode =&amp;gt; (int) 200
      [private] protocol =&amp;gt; &amp;#039;1.1&amp;#039;
      [private] stream =&amp;gt; object(Zend\Diactoros\Stream) {}
  }
  $maxBufferLength = (int) 8192
  $file = &amp;#039;/home/southpac/southpacificavionics.com/team/src/Controller/CustomersController.php&amp;#039;
  $line = (int) 179
  $message = &amp;#039;Unable to emit headers. Headers sent in file=/home/southpac/southpacificavionics.com/team/src/Controller/CustomersController.php line=179&amp;#039;&lt;/pre&gt;&lt;pre class="stack-trace"&gt;Cake\Http\ResponseEmitter::emit() - CORE/src/Http/ResponseEmitter.php, line 48
  Cake\Http\Server::emit() - CORE/src/Http/Server.php, line 116
  [main] - ROOT/webroot/index.php, line 37&lt;/pre&gt;&lt;/div&gt;&lt;/pre&gt;&lt;pre class="cake-error"&gt;&lt;a href="javascript:void(0);" onclick="document.getElementById('cakeErr5a1140bb8392c-trace').style.display = (document.getElementById('cakeErr5a1140bb8392c-trace').style.display == 'none' ? '' : 'none');"&gt;&lt;b&gt;Warning&lt;/b&gt; (2)&lt;/a&gt;: Cannot modify header information - headers already sent by (output started at /home/southpac/southpacificavionics.com/team/src/Controller/CustomersController.php:179) [&lt;b&gt;CORE/src/Http/ResponseEmitter.php&lt;/b&gt;, line &lt;b&gt;146&lt;/b&gt;]&lt;div id="cakeErr5a1140bb8392c-trace" class="cake-stack-trace" style="display: none;"&gt;&lt;a href="javascript:void(0);" onclick="document.getElementById('cakeErr5a1140bb8392c-code').style.display = (document.getElementById('cakeErr5a1140bb8392c-code').style.display == 'none' ? '' : 'none')"&gt;Code&lt;/a&gt; &lt;a href="javascript:void(0);" onclick="document.getElementById('cakeErr5a1140bb8392c-context').style.display = (document.getElementById('cakeErr5a1140bb8392c-context').style.display == 'none' ? '' : 'none')"&gt;Context&lt;/a&gt;&lt;pre id="cakeErr5a1140bb8392c-code" class="cake-code-dump" style="display: none;"&gt;&lt;code&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000BB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$response&lt;/span&gt;&lt;span style="color: #007700"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: #0000BB"&gt;getStatusCode&lt;/span&gt;&lt;span style="color: #007700"&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;
  &lt;span class="code-highlight"&gt;&lt;code&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000BB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;(&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$reasonPhrase&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;?&amp;nbsp;&lt;/span&gt;&lt;span style="color: #DD0000"&gt;'&amp;nbsp;'&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;.&amp;nbsp;&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$reasonPhrase&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;:&amp;nbsp;&lt;/span&gt;&lt;span style="color: #DD0000"&gt;''&lt;/span&gt;&lt;span style="color: #007700"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;
  &lt;code&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000BB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre id="cakeErr5a1140bb8392c-context" class="cake-context" style="display: none;"&gt;$response = object(Zend\Diactoros\Response) {
      [protected] headers =&amp;gt; [
          &amp;#039;Content-Type&amp;#039; =&amp;gt; [
              [maximum depth reached]
          ]
      ]
      [protected] headerNames =&amp;gt; [
          &amp;#039;content-type&amp;#039; =&amp;gt; &amp;#039;Content-Type&amp;#039;
      ]
      [private] phrases =&amp;gt; [
          (int) 100 =&amp;gt; &amp;#039;Continue&amp;#039;,
          (int) 101 =&amp;gt; &amp;#039;Switching Protocols&amp;#039;,
          (int) 102 =&amp;gt; &amp;#039;Processing&amp;#039;,
          (int) 200 =&amp;gt; &amp;#039;OK&amp;#039;,
          (int) 201 =&amp;gt; &amp;#039;Created&amp;#039;,
          (int) 202 =&amp;gt; &amp;#039;Accepted&amp;#039;,
          (int) 203 =&amp;gt; &amp;#039;Non-Authoritative Information&amp;#039;,
          (int) 204 =&amp;gt; &amp;#039;No Content&amp;#039;,
          (int) 205 =&amp;gt; &amp;#039;Reset Content&amp;#039;,
          (int) 206 =&amp;gt; &amp;#039;Partial Content&amp;#039;,
          (int) 207 =&amp;gt; &amp;#039;Multi-status&amp;#039;,
          (int) 208 =&amp;gt; &amp;#039;Already Reported&amp;#039;,
          (int) 226 =&amp;gt; &amp;#039;IM used&amp;#039;,
          (int) 300 =&amp;gt; &amp;#039;Multiple Choices&amp;#039;,
          (int) 301 =&amp;gt; &amp;#039;Moved Permanently&amp;#039;,
          (int) 302 =&amp;gt; &amp;#039;Found&amp;#039;,
          (int) 303 =&amp;gt; &amp;#039;See Other&amp;#039;,
          (int) 304 =&amp;gt; &amp;#039;Not Modified&amp;#039;,
          (int) 305 =&amp;gt; &amp;#039;Use Proxy&amp;#039;,
          (int) 306 =&amp;gt; &amp;#039;Switch Proxy&amp;#039;,
          (int) 307 =&amp;gt; &amp;#039;Temporary Redirect&amp;#039;,
          (int) 308 =&amp;gt; &amp;#039;Permanent Redirect&amp;#039;,
          (int) 400 =&amp;gt; &amp;#039;Bad Request&amp;#039;,
          (int) 401 =&amp;gt; &amp;#039;Unauthorized&amp;#039;,
          (int) 402 =&amp;gt; &amp;#039;Payment Required&amp;#039;,
          (int) 403 =&amp;gt; &amp;#039;Forbidden&amp;#039;,
          (int) 404 =&amp;gt; &amp;#039;Not Found&amp;#039;,
          (int) 405 =&amp;gt; &amp;#039;Method Not Allowed&amp;#039;,
          (int) 406 =&amp;gt; &amp;#039;Not Acceptable&amp;#039;,
          (int) 407 =&amp;gt; &amp;#039;Proxy Authentication Required&amp;#039;,
          (int) 408 =&amp;gt; &amp;#039;Request Time-out&amp;#039;,
          (int) 409 =&amp;gt; &amp;#039;Conflict&amp;#039;,
          (int) 410 =&amp;gt; &amp;#039;Gone&amp;#039;,
          (int) 411 =&amp;gt; &amp;#039;Length Required&amp;#039;,
          (int) 412 =&amp;gt; &amp;#039;Precondition Failed&amp;#039;,
          (int) 413 =&amp;gt; &amp;#039;Request Entity Too Large&amp;#039;,
          (int) 414 =&amp;gt; &amp;#039;Request-URI Too Large&amp;#039;,
          (int) 415 =&amp;gt; &amp;#039;Unsupported Media Type&amp;#039;,
          (int) 416 =&amp;gt; &amp;#039;Requested range not satisfiable&amp;#039;,
          (int) 417 =&amp;gt; &amp;#039;Expectation Failed&amp;#039;,
          (int) 418 =&amp;gt; &amp;#039;I&amp;#039;m a teapot&amp;#039;,
          (int) 421 =&amp;gt; &amp;#039;Misdirected Request&amp;#039;,
          (int) 422 =&amp;gt; &amp;#039;Unprocessable Entity&amp;#039;,
          (int) 423 =&amp;gt; &amp;#039;Locked&amp;#039;,
          (int) 424 =&amp;gt; &amp;#039;Failed Dependency&amp;#039;,
          (int) 425 =&amp;gt; &amp;#039;Unordered Collection&amp;#039;,
          (int) 426 =&amp;gt; &amp;#039;Upgrade Required&amp;#039;,
          (int) 428 =&amp;gt; &amp;#039;Precondition Required&amp;#039;,
          (int) 429 =&amp;gt; &amp;#039;Too Many Requests&amp;#039;,
          (int) 431 =&amp;gt; &amp;#039;Request Header Fields Too Large&amp;#039;,
          (int) 444 =&amp;gt; &amp;#039;Connection Closed Without Response&amp;#039;,
          (int) 451 =&amp;gt; &amp;#039;Unavailable For Legal Reasons&amp;#039;,
          (int) 499 =&amp;gt; &amp;#039;Client Closed Request&amp;#039;,
          (int) 500 =&amp;gt; &amp;#039;Internal Server Error&amp;#039;,
          (int) 501 =&amp;gt; &amp;#039;Not Implemented&amp;#039;,
          (int) 502 =&amp;gt; &amp;#039;Bad Gateway&amp;#039;,
          (int) 503 =&amp;gt; &amp;#039;Service Unavailable&amp;#039;,
          (int) 504 =&amp;gt; &amp;#039;Gateway Time-out&amp;#039;,
          (int) 505 =&amp;gt; &amp;#039;HTTP Version not supported&amp;#039;,
          (int) 506 =&amp;gt; &amp;#039;Variant Also Negotiates&amp;#039;,
          (int) 507 =&amp;gt; &amp;#039;Insufficient Storage&amp;#039;,
          (int) 508 =&amp;gt; &amp;#039;Loop Detected&amp;#039;,
          (int) 510 =&amp;gt; &amp;#039;Not Extended&amp;#039;,
          (int) 511 =&amp;gt; &amp;#039;Network Authentication Required&amp;#039;,
          (int) 599 =&amp;gt; &amp;#039;Network Connect Timeout Error&amp;#039;
      ]
      [private] reasonPhrase =&amp;gt; &amp;#039;OK&amp;#039;
      [private] statusCode =&amp;gt; (int) 200
      [private] protocol =&amp;gt; &amp;#039;1.1&amp;#039;
      [private] stream =&amp;gt; object(Zend\Diactoros\Stream) {}
  }
  $reasonPhrase = &amp;#039;OK&amp;#039;&lt;/pre&gt;&lt;pre class="stack-trace"&gt;header - [internal], line ??
  Cake\Http\ResponseEmitter::emitStatusLine() - CORE/src/Http/ResponseEmitter.php, line 146
  Cake\Http\ResponseEmitter::emit() - CORE/src/Http/ResponseEmitter.php, line 54
  Cake\Http\Server::emit() - CORE/src/Http/Server.php, line 116
  [main] - ROOT/webroot/index.php, line 37&lt;/pre&gt;&lt;/div&gt;&lt;/pre&gt;&lt;pre class="cake-error"&gt;&lt;a href="javascript:void(0);" onclick="document.getElementById('cakeErr5a1140bb83ee9-trace').style.display = (document.getElementById('cakeErr5a1140bb83ee9-trace').style.display == 'none' ? '' : 'none');"&gt;&lt;b&gt;Warning&lt;/b&gt; (2)&lt;/a&gt;: Cannot modify header information - headers already sent by (output started at /home/southpac/southpacificavionics.com/team/src/Controller/CustomersController.php:179) [&lt;b&gt;CORE/src/Http/ResponseEmitter.php&lt;/b&gt;, line &lt;b&gt;173&lt;/b&gt;]&lt;div id="cakeErr5a1140bb83ee9-trace" class="cake-stack-trace" style="display: none;"&gt;&lt;a href="javascript:void(0);" onclick="document.getElementById('cakeErr5a1140bb83ee9-code').style.display = (document.getElementById('cakeErr5a1140bb83ee9-code').style.display == 'none' ? '' : 'none')"&gt;Code&lt;/a&gt; &lt;a href="javascript:void(0);" onclick="document.getElementById('cakeErr5a1140bb83ee9-context').style.display = (document.getElementById('cakeErr5a1140bb83ee9-context').style.display == 'none' ? '' : 'none')"&gt;Context&lt;/a&gt;&lt;pre id="cakeErr5a1140bb83ee9-code" class="cake-code-dump" style="display: none;"&gt;&lt;code&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000BB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$name&lt;/span&gt;&lt;span style="color: #007700"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;
  &lt;span class="code-highlight"&gt;&lt;code&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000BB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$value&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;
  &lt;code&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000BB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;),&amp;nbsp;&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$first&lt;/span&gt;&lt;span style="color: #007700"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre id="cakeErr5a1140bb83ee9-context" class="cake-context" style="display: none;"&gt;$response = object(Zend\Diactoros\Response) {
      [protected] headers =&amp;gt; [
          &amp;#039;Content-Type&amp;#039; =&amp;gt; [
              [maximum depth reached]
          ]
      ]
      [protected] headerNames =&amp;gt; [
          &amp;#039;content-type&amp;#039; =&amp;gt; &amp;#039;Content-Type&amp;#039;
      ]
      [private] phrases =&amp;gt; [
          (int) 100 =&amp;gt; &amp;#039;Continue&amp;#039;,
          (int) 101 =&amp;gt; &amp;#039;Switching Protocols&amp;#039;,
          (int) 102 =&amp;gt; &amp;#039;Processing&amp;#039;,
          (int) 200 =&amp;gt; &amp;#039;OK&amp;#039;,
          (int) 201 =&amp;gt; &amp;#039;Created&amp;#039;,
          (int) 202 =&amp;gt; &amp;#039;Accepted&amp;#039;,
          (int) 203 =&amp;gt; &amp;#039;Non-Authoritative Information&amp;#039;,
          (int) 204 =&amp;gt; &amp;#039;No Content&amp;#039;,
          (int) 205 =&amp;gt; &amp;#039;Reset Content&amp;#039;,
          (int) 206 =&amp;gt; &amp;#039;Partial Content&amp;#039;,
          (int) 207 =&amp;gt; &amp;#039;Multi-status&amp;#039;,
          (int) 208 =&amp;gt; &amp;#039;Already Reported&amp;#039;,
          (int) 226 =&amp;gt; &amp;#039;IM used&amp;#039;,
          (int) 300 =&amp;gt; &amp;#039;Multiple Choices&amp;#039;,
          (int) 301 =&amp;gt; &amp;#039;Moved Permanently&amp;#039;,
          (int) 302 =&amp;gt; &amp;#039;Found&amp;#039;,
          (int) 303 =&amp;gt; &amp;#039;See Other&amp;#039;,
          (int) 304 =&amp;gt; &amp;#039;Not Modified&amp;#039;,
          (int) 305 =&amp;gt; &amp;#039;Use Proxy&amp;#039;,
          (int) 306 =&amp;gt; &amp;#039;Switch Proxy&amp;#039;,
          (int) 307 =&amp;gt; &amp;#039;Temporary Redirect&amp;#039;,
          (int) 308 =&amp;gt; &amp;#039;Permanent Redirect&amp;#039;,
          (int) 400 =&amp;gt; &amp;#039;Bad Request&amp;#039;,
          (int) 401 =&amp;gt; &amp;#039;Unauthorized&amp;#039;,
          (int) 402 =&amp;gt; &amp;#039;Payment Required&amp;#039;,
          (int) 403 =&amp;gt; &amp;#039;Forbidden&amp;#039;,
          (int) 404 =&amp;gt; &amp;#039;Not Found&amp;#039;,
          (int) 405 =&amp;gt; &amp;#039;Method Not Allowed&amp;#039;,
          (int) 406 =&amp;gt; &amp;#039;Not Acceptable&amp;#039;,
          (int) 407 =&amp;gt; &amp;#039;Proxy Authentication Required&amp;#039;,
          (int) 408 =&amp;gt; &amp;#039;Request Time-out&amp;#039;,
          (int) 409 =&amp;gt; &amp;#039;Conflict&amp;#039;,
          (int) 410 =&amp;gt; &amp;#039;Gone&amp;#039;,
          (int) 411 =&amp;gt; &amp;#039;Length Required&amp;#039;,
          (int) 412 =&amp;gt; &amp;#039;Precondition Failed&amp;#039;,
          (int) 413 =&amp;gt; &amp;#039;Request Entity Too Large&amp;#039;,
          (int) 414 =&amp;gt; &amp;#039;Request-URI Too Large&amp;#039;,
          (int) 415 =&amp;gt; &amp;#039;Unsupported Media Type&amp;#039;,
          (int) 416 =&amp;gt; &amp;#039;Requested range not satisfiable&amp;#039;,
          (int) 417 =&amp;gt; &amp;#039;Expectation Failed&amp;#039;,
          (int) 418 =&amp;gt; &amp;#039;I&amp;#039;m a teapot&amp;#039;,
          (int) 421 =&amp;gt; &amp;#039;Misdirected Request&amp;#039;,
          (int) 422 =&amp;gt; &amp;#039;Unprocessable Entity&amp;#039;,
          (int) 423 =&amp;gt; &amp;#039;Locked&amp;#039;,
          (int) 424 =&amp;gt; &amp;#039;Failed Dependency&amp;#039;,
          (int) 425 =&amp;gt; &amp;#039;Unordered Collection&amp;#039;,
          (int) 426 =&amp;gt; &amp;#039;Upgrade Required&amp;#039;,
          (int) 428 =&amp;gt; &amp;#039;Precondition Required&amp;#039;,
          (int) 429 =&amp;gt; &amp;#039;Too Many Requests&amp;#039;,
          (int) 431 =&amp;gt; &amp;#039;Request Header Fields Too Large&amp;#039;,
          (int) 444 =&amp;gt; &amp;#039;Connection Closed Without Response&amp;#039;,
          (int) 451 =&amp;gt; &amp;#039;Unavailable For Legal Reasons&amp;#039;,
          (int) 499 =&amp;gt; &amp;#039;Client Closed Request&amp;#039;,
          (int) 500 =&amp;gt; &amp;#039;Internal Server Error&amp;#039;,
          (int) 501 =&amp;gt; &amp;#039;Not Implemented&amp;#039;,
          (int) 502 =&amp;gt; &amp;#039;Bad Gateway&amp;#039;,
          (int) 503 =&amp;gt; &amp;#039;Service Unavailable&amp;#039;,
          (int) 504 =&amp;gt; &amp;#039;Gateway Time-out&amp;#039;,
          (int) 505 =&amp;gt; &amp;#039;HTTP Version not supported&amp;#039;,
          (int) 506 =&amp;gt; &amp;#039;Variant Also Negotiates&amp;#039;,
          (int) 507 =&amp;gt; &amp;#039;Insufficient Storage&amp;#039;,
          (int) 508 =&amp;gt; &amp;#039;Loop Detected&amp;#039;,
          (int) 510 =&amp;gt; &amp;#039;Not Extended&amp;#039;,
          (int) 511 =&amp;gt; &amp;#039;Network Authentication Required&amp;#039;,
          (int) 599 =&amp;gt; &amp;#039;Network Connect Timeout Error&amp;#039;
      ]
      [private] reasonPhrase =&amp;gt; &amp;#039;OK&amp;#039;
      [private] statusCode =&amp;gt; (int) 200
      [private] protocol =&amp;gt; &amp;#039;1.1&amp;#039;
      [private] stream =&amp;gt; object(Zend\Diactoros\Stream) {}
  }
  $name = &amp;#039;Content-Type&amp;#039;
  $values = [
      (int) 0 =&amp;gt; &amp;#039;text/html; charset=UTF-8&amp;#039;
  ]
  $first = true
  $value = &amp;#039;text/html; charset=UTF-8&amp;#039;&lt;/pre&gt;&lt;pre class="stack-trace"&gt;header - [internal], line ??
  Cake\Http\ResponseEmitter::emitHeaders() - CORE/src/Http/ResponseEmitter.php, line 173
  Cake\Http\ResponseEmitter::emit() - CORE/src/Http/ResponseEmitter.php, line 55
  Cake\Http\Server::emit() - CORE/src/Http/Server.php, line 116
  [main] - ROOT/webroot/index.php, line 37&lt;/pre&gt;&lt;/div&gt;&lt;/pre&gt;
  </code></pre>