/** * Initialise the step 4 form * * @return void */ public function step4Action() { // Append the address lookup javascript $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = 4;'); $pageForm = new LettingAgents_Form_Step4(); $pageSession = new Zend_Session_Namespace('letting_agents_application'); // Setup an agency object $agent = new LettingAgents_Manager_AgentApplication(); $agentData = new LettingAgents_Object_AgentApplication(); $agentData = $agent->fetchByUid($pageSession->agentUniqueId); if ($this->getRequest()->isPost()) { // We need to validate and save the data // TODO: Need to re-factor this to make it quicker $valid = $this->_formStepCommonValidate($pageForm, 4); if ($valid) { $postData = $pageForm->getValues(); //Zend_Debug::dump($postData);die(); switch ($postData['subform_agenttype']['agent_type']) { case "standard": $agentType = LettingAgents_Object_AgentTypes::Standard; break; case "premier": $agentType = LettingAgents_Object_AgentTypes::Premier; break; default: $agentType = LettingAgents_Object_AgentTypes::Standard; } $agentData->set_application_type($agentType); // Stuff gets saved here $agent->save($agentData); $this->_formStepCommonNavigate(4); return; } elseif (isset($_POST['back'])) { $this->_formStepCommonNavigate(4); return; } } // Load the element data from the database if we can if ($this->_formStepCommonPopulate($pageForm, 4)) { // Render the page unless we have been redirected $this->view->form = $pageForm; $this->render('step'); } }