/** * Provides all the necessary forms needed to start an update. * @param $params * @return unknown_type */ public function import($params) { if ($params[0] == 'execute') { $this->doImport(); die; } $data = array(); $form = new Form(); $form->add(Element::create("FileUploadField", "File", "file", "Select the file you want to upload.")->setScript($this->urlPath . "/import/execute")->setJsExpression("wyf.showUploadedData(callback_data)"), Element::create("Checkbox", "Break on errors", "break_on_errors", "", "1")->setValue("1")); $form->setRenderer("default"); $form->addAttribute("style", "width:400px"); $form->setShowSubmit(false); $data["form"] = $form->render(); return array("template" => "file:" . getcwd() . "/lib/controllers/import.tpl", "data" => $data); }
/** * Provides all the necessary forms needed to start an update. * @param $params * @return string */ public function import() { $this->label = "Import " . $this->label; $form = new Form(); $form->add(Element::create("UploadField", "File", "file", "Select the file you want to upload."), Element::create("Checkbox", "Break on errors", "break_on_errors", "", "1")->setValue("1")); $form->addAttribute("style", "width:50%"); $form->setCallback($this->getClassName() . '::importCallback', $this); $form->setSubmitValue('Import Data'); return $this->arbitraryTemplate(Application::getWyfHome('model_controller/import.tpl'), array('form' => $form->render(), 'template' => "{$this->path}/export/csv?template=yes")); }
/** * Provides all the necessary forms needed to start an update. * @param $params * @return string */ public function import() { $this->label = "Import " . $this->label; $entity = $this->model->getEntity(); $path = $this->urlPath; $form = new Form(); $form->setRenderer('default'); $form->add(Element::create("HTMLBox", "This import utility would assist you to import new {$entity} into your database. You are expected to upload a CSV file which contains the data you want to import." . " <p>Please click <a href='{$path}/export/csv?template=yes'>here</a> to download a template csv file.</p>"), Element::create("UploadField", "File", "file", "Select the file you want to upload.")); $form->addAttribute("style", "width:50%"); $form->setCallback($this->getClassName() . '::importCallback', $this); $form->setSubmitValue('Import Data'); return $this->arbitraryTemplate(Application::getWyfHome('utils/model_controller/templates/import.tpl'), array('form' => $form->render())); }