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

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 !!!!