/** * Add the elements from the model to the bridge for file check step * * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge * @param \MUtil_Model_ModelAbstract $model */ protected function addStepChangeTrack(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $this->displayHeader($bridge, $this->_('Change track information.'), 'h3'); // Load the import data form settings $this->loadImportData(); // Always add organization select, even when they were not exported $this->addItems($bridge, $model->getColNames('respondentData')); // \MUtil_Echo::track($this->formData); $all = $this->loader->getUtil()->getTrackData()->getAllSurveys(); $available = array('' => $this->_('(skip rounds)')) + $all; // \MUtil_Echo::track($all); $form = $bridge->getForm(); $surveyHeader = $form->createElement('Html', 'sheader1'); $surveyHeader->h2($this->_('Survey export code links')); $form->addElement($surveyHeader); $surveySubHeader = $form->createElement('Html', 'sheader2'); $surveySubHeader->strong($this->_('Linked survey name')); $surveySubHeader->setLabel($this->_('Import survey name'))->setDescription(sprintf($this->_('[%s]'), $this->_('export code')))->setRequired(true); $form->addElement($surveySubHeader); $this->addItems($bridge, $model->getColNames('isSurvey')); // \MUtil_Echo::track($this->_session->uploadFileName, $import->getArrayCopy()); }
/** * Hook that loads the form data from $_POST or the model * * Or from whatever other source you specify here. */ protected function loadFormData() { if ($this->request->isPost()) { $this->formData = $this->request->getPost() + $this->formData; } else { foreach ($this->importModel->getColNames('default') as $name) { if (!(isset($this->formData[$name]) && $this->formData[$name])) { $this->formData[$name] = $this->importModel->get($name, 'default'); } } } if (!(isset($this->formData['import_id']) && $this->formData['import_id'])) { $this->formData['import_id'] = mt_rand(10000, 99999) . time(); } $this->_session = new \Zend_Session_Namespace(__CLASS__ . '-' . $this->formData['import_id']); if (isset($this->formData[$this->stepFieldName]) && $this->formData[$this->stepFieldName] > 1 && !(isset($this->_session->localfile) && $this->_session->localfile)) { $this->_session->localfile = \MUtil_File::createTemporaryIn($this->tempDirectory, $this->request->getControllerName() . '_'); } // Must always exists $this->fileMode = 'file' === $this->formData['mode']; // Set the translator $translator = $this->getImportTranslator(); if ($translator instanceof \MUtil_Model_ModelTranslatorInterface) { $this->importer->setImportTranslator($translator); } // \MUtil_Echo::track($_POST, $_FILES, $this->formData); }