Hi,
I would like to retrieve the data in each NAV tab only once till saved or discarded. I setup session variable to indicate that tab data is retrieved and should not be retrieved when tab is selected again for editing but the value of this variable not retained across each tab click. The EmployeeForm
gets retrieved every time. I am not sure why this is happening. Is that the way its supposed to work. Here is the code:
class EmployeeController extends IndexController
{
public function initialize()
{
$this->session->set("tabRetrieved", 0);
parent::initialize();
...
}
public function editAction($hr_emp_iid)
{
$tabRetrieved = $this->session->get("tabRetrieved") ;
echo '1 TabR Value: '. $this->session->get("tabRetrieved") ."<br/>" ;
if (!$tabRetrieved) {
echo 'tabRetrieved : ' . $tabRetrieved. ' . "\r\n" ;
$employee = HrEmployeeM::findFirst(....);
if (!$employee) {
$this->flash->error("Employee was not found");
return $this->dispatcher->forward(array(
'action' => 'index'
));
}
$this->view->form = new EmployeeForm($employee, array( 'edit' => true ));
$this->session->set("tabRetrieved", 1);
echo '2 TabR Value: '. $this->session->get("tabRetrieved")."<br/>" ;
.....
I tried using $this->persistent->tabRetrieved
also but same result. Value of these variables doesn't seem to be retained in both cases or I am doing something wrong. Is this the correct way to code?
Amal