Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>But there doesn't appear to be a response ... and the contents of #message_board are emptied.</p> </blockquote> <p>That is because you haven't set what action/view to render. You have to do this manually since you have <code>$this-&gt;autoRender</code> set to <code>false</code>. You could use <code>render()</code> to do this. More info can be found at <a href="http://book.cakephp.org/view/980/render" rel="nofollow">its respective cookbook page</a>.</p> <p>If you have <code>$this-&gt;autoRender</code> set to <code>true</code>, then it'll replace the contents of #message_board with the contents of <code>add.ctp</code></p> <hr> <blockquote> <p>The flash message "Add action called" is NOT set from the controller (or any of the flash messages, for that matter)</p> </blockquote> <p>I think you have to refresh the page or the part which contains the <code>$this-&gt;Session-&gt;flash()</code> bit for flash messages to appear.</p> <p>The fact that the flash message appeared when you refreshed the page means that it did call and run the action.</p> <p>AFAIK, you can only put/print one message from the flash key in the <code>Messages</code> array. The flash key is where the flash messages are stored by default. Each call to <code>setFlash()</code> will overwrite the flash message set by older calls.</p> <p>Since only the second flash message was displayed, we could say that it failed at passing at least one of the conditions following the second call to <code>setFlash()</code> in the controller. You might want to put <code>debug($this-&gt;data)</code> statements near the conditions related to <code>$this-&gt;data</code> to help yourself in debugging your problem.</p> <p>You could also use <code>debug()</code> to know if your application went through a certain action or path since it will almost always be displayed.</p> <p>So you could do the following to check if it passed this condition:</p> <pre><code> if(!empty($this-&gt;data)) { debug('Passed!'); </code></pre> <p>If 'Passed!' will be printed after submitting the form, we would know that it passed that condition.</p> <hr> <blockquote> <p>However the new message was not saved</p> </blockquote> <p>It might be because $data is empty or it failed at validation. If your <code>$data</code> is not empty, it might have failed at validation and since your form doesn't display the validation errors; you might never have noticed them. One way to know if it passed validation is to do the following:</p> <pre><code> $this-&gt;Message-&gt;set($this-&gt;data); if ($this-&gt;Message-&gt;validates()) { debug('it validated logic'); } else { debug('didn't validate logic'); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload