protected function _referenceSubjectTerms()
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $session->currentFlowItem = Model_Referencing_DataEntry_FlowItems::TERMS;
     $termsForm = new LandlordsReferencing_Form_Terms();
     //Tell page to use AJAX validation as we go
     $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = "terms";');
     $request = $this->getRequest();
     $data = $request->getPost();
     if ($request->isPost()) {
         if ($termsForm->isValid($data)) {
             //Extract clean values, save them and validate
             $data = $termsForm->getValues();
             //Capture the data.
             if ($data['terms_agreed'] == 'Yes') {
                 $this->_storeDataProtections();
                 //Update the progress.
                 $progressManager = new Manager_Referencing_Progress();
                 $referenceManager = new Manager_Referencing_Reference();
                 $reference = $referenceManager->getReference($session->referenceId);
                 if (empty($reference->progress)) {
                     //Create new progress object.
                     $reference->progress = $progressManager->createNewProgress($reference->internalId);
                     //Add a new progress item to the progress object.
                     $reference->progress->items[] = $progressManager->createNewProgressItem(Model_Referencing_ProgressItemVariables::TERMS_AGREED, Model_Referencing_ProgressItemStates::COMPLETE);
                 } else {
                     //Retrieve possible existing TERMS_AGREED progress item variable.
                     $progressItem = $progressManager->findSpecificProgressItem($reference->progress, Model_Referencing_ProgressItemVariables::TERMS_AGREED);
                     if (empty($progressItem)) {
                         //Doesn't exist, so create.
                         $reference->progress->items[] = $progressManager->createNewProgressItem(Model_Referencing_ProgressItemVariables::TERMS_AGREED, Model_Referencing_ProgressItemStates::COMPLETE);
                     } else {
                         //Exists so update.
                         $progressItem->itemState = Model_Referencing_ProgressItemStates::COMPLETE;
                     }
                 }
                 $referenceManager->updateReference($reference);
                 $this->_despatchToNext();
                 return;
             }
             //If here then the user clicked 'No' to the terms and conditions. As per the
             //behaviour of the previous generation of this system, simply re-display
             //the form.
         } else {
             $previouslyLoaded = "var previouslyLoaded = true;\n";
             $this->view->headScript()->appendScript($previouslyLoaded, $type = 'text/javascript');
         }
     }
     $termsForm->populate($termsForm->getValues());
     //Set this to whatever you want the progress bar to how in percents
     $this->view->fractionComplete = 95;
     $this->view->form = $termsForm;
 }