Example #1
0
 /**
  * execute
  *
  * @param \Form\Form $form
  */
 public function update($form)
 {
     /* @var $object \coa\Db\CoaSetup */
     $object = $form->getObject();
     /* @var $file \Form\Field\File */
     $file = $form->getField('pdfBgImage');
     if ($object instanceof \Tk\Db\Model) {
         $form->loadObject($object);
         $form->addFieldErrors($object->getValidator()->getErrors());
     }
     if ($form->hasErrors()) {
         if (!\Mod\Notice::hasMessages()) {
             \Mod\Notice::addError('The form contains errors.');
         }
         return;
     }
     $object->save();
     if ($file && $file->hasFile()) {
         $path = $object->getBasePath();
         \Tk\Path::rmdir($this->getConfig()->getDataPath() . $path);
         $file->moveUploadedFile($this->getConfig()->getDataPath() . $path . '/' . $file->getFileName());
         $object->pdfBgImage = $path . '/' . $file->getFileName();
         $object->save();
     }
     \Mod\Notice::addSuccess('Form submission successful');
 }