Lançado Adianti Framework 8.1!
Clique aqui para saber mais
TMULTIFILE - ERRO AO SALVAR O REGISTRO. NÃO SALVA NA PASTA ESPEC Quando uso Tfile, o programa salva o arquivo perfeitamente na pasta files/upload Ao trocar TFile por TMultiFile, e escolho 2 arquivos, ao salvar dá erro e não cria a subpasta e não grava os arquivos selecionados(/b> Warning: urldecode() expects parameter 1 to be string, array given in C:xampphtdocsocorrenciaslibadiantibaseAdiantiFileSaveTrait.php on ...
CD
TMULTIFILE - ERRO AO SALVAR O REGISTRO. NÃO SALVA NA PASTA ESPEC  
Quando uso Tfile, o programa salva o arquivo perfeitamente na pasta files/upload

Ao trocar TFile por TMultiFile, e escolho 2 arquivos, ao salvar dá erro e não cria a subpasta e não grava os arquivos selecionados(/b>


Warning: urldecode() expects parameter 1 to be string, array given in C:xampphtdocsocorrenciaslibadiantibaseAdiantiFileSaveTrait.php on


  1. <?php
  2. /**
  3.  * ocorrenciaForm Form
  4.  * @author  <your name here>
  5.  */
  6. class ocorrenciaForm extends TPage
  7. {
  8.     protected $form// form
  9.     
  10.     use Adianti\Base\AdiantiFileSaveTrait;   
  11.     /**
  12.      * Form constructor
  13.      * @param $param Request
  14.      */
  15.     public function __construct$param )
  16.     {
  17.         parent::__construct();
  18.         
  19.         
  20.         // creates the form
  21.         $this->form = new BootstrapFormBuilder('form_ocorrencia');
  22.         $this->form->setFormTitle('Lançamento de Ocorrências');
  23.         
  24.         // create the form fields
  25.         $ID_OCORRENCIA = new TEntry('ID_OCORRENCIA');
  26.         $ID_NAVIO = new TDBCombo('ID_NAVIO''datasiop''navio''ID_NAVIO''NOME');
  27.         $ID_TURNO = new TDBCombo('ID_TURNO''datasiop''turno''ID_TURNO''DESCRICAO');
  28.         $ID_TIPO_OCORRENCIA = new TDBCombo('ID_TIPO_OCORRENCIA''datasiop''tipo_ocorrencia''ID_TIPO_OCORRENCIA''DESCRICAO');
  29.         $ID_CLIENTE = new TDBCombo('ID_CLIENTE''datasiop''cliente''ID_CLIENTE''NOME');
  30.         $DESCRICAO = new TText('DESCRICAO');
  31.         $ACAO_IMEDIATA = new TText('ACAO_IMEDIATA');
  32.         $DATA_OCORRENCIA = new TDate('DATA_OCORRENCIA');
  33.         $HORA_INI = new TEntry('HORA_INI');
  34.         $HORA_FIM = new TEntry('HORA_FIM');
  35.         $CHUVA_MM = new TEntry('CHUVA_MM');
  36.         $ARQUIVOS_PATH = new TMultiFile('ARQUIVOS_PATH');
  37.         
  38.         
  39.         // definição de mascaras
  40.         $DATA_OCORRENCIA->setmask('dd/mm/yyyy');
  41.         $DATA_OCORRENCIA->setdatabasemask('yyyy-mm-dd');
  42.       
  43.         /* setmask('hh:ii')
  44.            setnumericmask(2,',','.',true)       
  45.         */
  46.         
  47.         $HORA_INI->setmask('00:00');
  48.         $HORA_FIM->setmask('00:00'); 
  49.         // adicionar itens numa Tcombo
  50.         //$campo->addItems(['M'=>'Masculino','F'=>'Feminino']);
  51.         $ARQUIVOS_PATH->enablefilehandling();
  52.         $ARQUIVOS_PATH->setallowedextensions(['png','jpg','pdf','doc']);
  53.        
  54.         // add the fields
  55.         $this->form->addFields( [ new TLabel('Id:') ], [ $ID_OCORRENCIA ] );
  56.         $this->form->addFields( [ new TLabel('Navio:') ], [ $ID_NAVIO ] );
  57.         $this->form->addFields( [ new TLabel('Turno:') ], [ $ID_TURNO ] );
  58.         $this->form->addFields( [ new TLabel('Tipo Ocorrência:') ], [ $ID_TIPO_OCORRENCIA ] );
  59.         $this->form->addFields( [ new TLabel('Cliente:') ], [ $ID_CLIENTE ] );
  60.         $this->form->addFields( [ new TLabel('Descrição:') ], [ $DESCRICAO ] );
  61.         $this->form->addFields( [ new TLabel('Ação Imediata:') ], [ $ACAO_IMEDIATA ] );
  62.         $this->form->addFields( [ new TLabel('Data Ocorrência:') ], [ $DATA_OCORRENCIA ] );
  63.         $this->form->addFields( [ new TLabel('Hora Ini:') ], [ $HORA_INI ] );
  64.         $this->form->addFields( [ new TLabel('Hora Fim:') ], [ $HORA_FIM ] );
  65.         $this->form->addFields( [ new TLabel('Chuva MM:') ], [ $CHUVA_MM ] );
  66.         $this->form->addFields( [ new TLabel('Upload Evidência:') ], [ $ARQUIVOS_PATH ] );
  67.         
  68.         $ID_NAVIO->addValidation('Id Navio', new TRequiredValidator);
  69.         $ID_TURNO->addValidation('Id Turno', new TRequiredValidator);
  70.         $ID_TIPO_OCORRENCIA->addValidation('Id Tipo Ocorrencia', new TRequiredValidator);
  71.         $ID_CLIENTE->addValidation('Id Cliente', new TRequiredValidator);
  72.         $DESCRICAO->addValidation('Descricao', new TRequiredValidator);
  73.         $DATA_OCORRENCIA->addValidation('Data Ocorrencia', new TRequiredValidator);
  74.         $HORA_INI->addValidation('Hora Ini', new TRequiredValidator);
  75.         // set sizes
  76.         $ID_OCORRENCIA->setSize('10%');
  77.         $ID_NAVIO->setSize('50%');
  78.         $ID_TURNO->setSize('20%');
  79.         $ID_TIPO_OCORRENCIA->setSize('50%');
  80.         $ID_CLIENTE->setSize('50%');
  81.         $DESCRICAO->setSize('70%');
  82.         $ACAO_IMEDIATA->setSize('70%');
  83.         $DATA_OCORRENCIA->setSize('20%');
  84.         $HORA_INI->setSize('10%');
  85.         $HORA_FIM->setSize('10%');
  86.         $CHUVA_MM->setSize('10%');
  87.         $ARQUIVOS_PATH->setSize('100%');
  88.         if (!empty($ID_OCORRENCIA))
  89.         {
  90.             $ID_OCORRENCIA->setEditable(FALSE);
  91.         }
  92.         
  93.         /** samples
  94.          $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  95.          $fieldX->setSize( '100%' ); // set size
  96.          **/
  97.          
  98.         // create the form actions
  99.         $btn $this->form->addAction(_t('Save'), new TAction([$this'onSave']), 'fa:save');
  100.         $btn->class 'btn btn-sm btn-primary';
  101.         $this->form->addActionLink(_t('New'),  new TAction([$this'onEdit']), 'fa:eraser red');
  102.         
  103.         // vertical box container
  104.         $container = new TVBox;
  105.         $container->style 'width: 100%';
  106.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  107.         $container->add($this->form);
  108.         
  109.         parent::add($container);
  110.     }
  111.     /**
  112.      * Save form data
  113.      * @param $param Request
  114.      */
  115.     public function onSave$param )
  116.     {
  117.         try
  118.         {
  119.             TTransaction::open('datasiop'); // open a transaction
  120.             
  121.             /**
  122.             // Enable Debug logger for SQL operations inside the transaction
  123.             TTransaction::setLogger(new TLoggerSTD); // standard output
  124.             TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  125.             **/
  126.             
  127.             $this->form->validate(); // validate form data
  128.             $data $this->form->getData(); // get form data as array
  129.             
  130.             $object = new ocorrencia;  // create an empty object
  131.             $object->fromArray( (array) $data); // load the object with data
  132.             $object->store(); // save the object
  133.             
  134.             $this->SaveFile($object,$data,'ARQUIVOS_PATH','files/uploads');
  135.             
  136.             // get the generated ID_OCORRENCIA
  137.             $data->ID_OCORRENCIA $object->ID_OCORRENCIA;
  138.             
  139.             $this->form->setData($data); // fill form data
  140.             TTransaction::close(); // close the transaction
  141.             
  142.             new TMessage('info'AdiantiCoreTranslator::translate('Record saved'));
  143.         }
  144.         catch (Exception $e// in case of exception
  145.         {
  146.             new TMessage('error'$e->getMessage()); // shows the exception error message
  147.             $this->form->setData$this->form->getData() ); // keep form data
  148.             TTransaction::rollback(); // undo all pending operations
  149.         }
  150.     }
  151.     
  152.     /**
  153.      * Clear form data
  154.      * @param $param Request
  155.      */
  156.     public function onClear$param )
  157.     {
  158.         $this->form->clear(TRUE);
  159.     }
  160.     
  161.     /**
  162.      * Load object to form data
  163.      * @param $param Request
  164.      */
  165.     public function onEdit$param )
  166.     {
  167.         try
  168.         {
  169.             if (isset($param['key']))
  170.             {
  171.                 $key $param['key'];  // get the parameter $key
  172.                 TTransaction::open('datasiop'); // open a transaction
  173.                 $object = new ocorrencia($key); // instantiates the Active Record
  174.                 $this->form->setData($object); // fill the form
  175.                 TTransaction::close(); // close the transaction
  176.             }
  177.             else
  178.             {
  179.                 $this->form->clear(TRUE);
  180.             }
  181.         }
  182.         catch (Exception $e// in case of exception
  183.         {
  184.             new TMessage('error'$e->getMessage()); // shows the exception error message
  185.             TTransaction::rollback(); // undo all pending operations
  186.         }
  187.     }
  188. }

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (2)


NR

Para o multifile a função é "saveFiles", no plural. E tem mais alguns parâmetros a informar:
https://adianti.com.br/framework_files/tutor/index.php?class=ProductForm&method=onEdit&id=1&key=1
CD

Obrigado amigão. Deu certo.

Valeu !!!!