[Zend Framework] Forms and success output
- by rasouza
Well,
It's a beginer'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 succeded or not in a div inside the same page.
So, basically, I have a form which action is setted 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';
$this->_redirect('/');
}
Then my view:
....
<?php if ($this->flagStatus) { ?>
<div id="divStatus" class="success span-5" style="display: none;">
<?php echo $this->flagStatus; ?>
</div>
<?php } ?>
....