Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>flashmessenger is really designed to be used on a redirect of some kind, so any message you see probably comes from the prior action's execution. Your current code would not flash any message during the first 'post'.</p> <p>you may have some luck if you try something like:</p> <pre><code>public function init() { //This will catch any messege set in any action in this controller and send //it to the view on the next request. if ($this-&gt;_helper-&gt;FlashMessenger-&gt;hasMessages()) { $this-&gt;view-&gt;messages = $this-&gt;_helper-&gt;FlashMessenger-&gt;getMessages(); } } public function someAction() { if(isset($_POST['submit'])) { // code to inputfields if(true) { //redirect to some page } else { // print the flash error on the same page $this-&gt;_helper-&gt;flashMessenger-&gt;addMessage(" This email is already taken"); //will redirect back to original url. May help, may not $this-&gt;_redirect($this-&gt;getRequest()-&gt;getRequestUri()); } } } </code></pre> <p>Here's an action I coded that demonstrates what you seem to be attempting.</p> <pre><code>public function updatetrackAction() { //get the page number $session = new Zend_Session_Namespace('page'); $id = $this-&gt;getRequest()-&gt;getParam('id'); //get the entity object $model = new Music_Model_Mapper_Track(); $track = $model-&gt;findById($id); //get the form $form = new Admin_Form_Track(); $form-&gt;setAction('/admin/music/updatetrack/'); //test for 'post' 'valid' and update info if ($this-&gt;getRequest()-&gt;isPost()) { if ($form-&gt;isValid($this-&gt;getRequest()-&gt;getPost())) { $data = $form-&gt;getValues(); $newTrack = new Music_Model_Track($data); $update = $model-&gt;saveTrack($newTrack); //add message $this-&gt;message-&gt;addMessage("Update of track '$update-&gt;title' complete!"); //redirects back to the same page number the request came from $this-&gt;getHelper('Redirector')-&gt;gotoSimple('update', null, null, array('page' =&gt; $session-&gt;page)); } } else { //if not post display current information //populate() only accepts an array - no objects - $form-&gt;populate($track-&gt;toArray()); $this-&gt;view-&gt;form = $form; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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