Exemple #1
0
 /**
  * @param $config SliceConfig
  * @return Form
  */
 public function _createSliceConfigUploadForm($config)
 {
     $form = new Form('upload');
     //load up our engines.
     if (User::isAdmin()) {
         $engines = SliceEngine::getAllEngines()->getAll();
     } else {
         $engines = SliceEngine::getPublicEngines()->getAll();
     }
     $engs = array();
     foreach ($engines as $row) {
         /* @var $e SliceEngine */
         $e = $row['SliceEngine'];
         $engs[$e->id] = $e->getName();
     }
     $form->add(SelectField::name('engine_id')->label('Slice Engine')->help('Which slicing engine does this config use?')->required(true)->value($config->get('engine_id'))->options($engs));
     $form->add(TextField::name('config_name')->label('Config Name')->help('What is the name of this slicing configuration.')->required(true)->value($config->get('config_name')));
     if ($config->isHydrated()) {
         $form->add(CheckboxField::name('expire_slicejobs')->label('Expire Old Slice Jobs')->help('If checked, old slice jobs will be expired and never re-used.')->value(1));
     }
     $form->add(UploadField::name('config_file')->label('Configuration File')->help('The configuration file to use (.ini for Slic3r)')->required(true));
     return $form;
 }
Exemple #2
0
 /**
  * @return Form
  */
 private function createFileForm()
 {
     /** @var Form $form */
     $form = new Form('file', true);
     /** @var StorageInterface $file */
     $file = Storage::newFile();
     $fields = $file->getUploadFields();
     foreach ($fields as $name => $value) {
         $form->add(HiddenField::name($name)->value($value));
     }
     $form->add(UploadField::name("file"));
     $form->setSubmitText("Upload File");
     $form->action = $file->getUploadURL();
     return $form;
 }