Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 790693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:43:19+00:00 2026-05-14T21:43:19+00:00

Well, It’s a beginner’s question but I really don’t know what is the best

  • 0

Well,

It’s a beginner’s question but I really don’t know what is the best way.
I have a basic CRUD (Create, Retrieve, Update and Delete) in my project and I’d like to output some message if succeeded or not in a div inside the same page.

So, basically, I have a form which action is set to the same page and I have a div #statusDiv below this same form which I’d like to output something like Register included with success.

What is the best way for doing this?

  • Set a flag in the controller $this->view->flagStatus = 'message' then call it in the view?

Just to make it more clear. It’s my code:

//IndexController.php indexAction()

...

//Check if there's submitted data
if ($this->getRequest()->isPost()) {
    ...
    $registries->insert($data);
    $this->view->flagStatus = 'message';
}

Then my view:

....
<?php if ($this->flagStatus) { ?>   
    <div id="divStatus" class="success span-5" style="display: none;">
        <?php echo $this->flagStatus; ?>
    </div>
<?php } ?>
....
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:43:19+00:00Added an answer on May 14, 2026 at 9:43 pm

    In this situation since you’re redirecting, the $this->view->flagStatus will be lost. Instead what you should use is the flashMessenger Action helper:

    http://framework.zend.com/manual/en/zend.controller.actionhelpers.html

    basically you use it just like you are currently, except you’d change:

    $this->view->flagStatus = 'message';
    

    to

    $this->_helper->flashMessenger->addMessage('message');
    

    after this you’ll need to send the flashMessenger object to the view. You should do this in a place that gets executed on every page request so you can send messages to any page:

    $this->view->flashMessenger = $this->_helper->flashMessenger;
    

    and then change your view to:

    <?php if($this->flashMessenger->hasMessages(): ?> 
        <div id="divStatus" class="success span-5" style="display: none;">
            <?php $messages = $this->flashMessenger->getMessages(); ?>
            <?php foreach($messages as $message): ?>
            <p><?= $message; ?></p>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>
    

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, I know there is a lots of posts about it, but I have
Well, I didn't really know how to call this... I have been surfing PayPal's
Well, i have the following need: create 3 dropdownlist with dependencies. My table in
Well, I have to revive a question that was answered here before. I've made
Well the title Question pretty much sums it up, But I'd like to detail
Well friends, I have got this query which works but is very long for
Well, this is my first post here and really enjoying the site. I have
Well... simple question, right? But with no so simple answers. In firefox i use
Well, it seems simple enough, but I can't find a way to add a
Well, having decided to get to know some of the basic functions in R

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.