Alerta ao trocar de TQuickForm para BootstrapFormBuider Olá amigos! Recentemente assinei o Adianti builder e o form passou a ser criado com a classe BootstrapFormBuilder e não com TQuickForm como eu usava anteriormente. Depois dessa mudança venho recebendo uma mensagem de alerta com o seguinte conteúdo: Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'AdiantiWidgetBaseTElement' does not have a method 'force...
GO
Alerta ao trocar de TQuickForm para BootstrapFormBuider  
Olá amigos!
Recentemente assinei o Adianti builder e o form passou a ser criado com a classe BootstrapFormBuilder e não com TQuickForm como eu usava anteriormente. Depois dessa mudança venho recebendo uma mensagem de alerta com o seguinte conteúdo:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'AdiantiWidgetBaseTElement' does not have a method 'forceUpperCase' in C:wamp64wwwgestaomedialibadiantiwidgetformTField.php on line 101

Meu código:

 
  1. <?php
 
  1. <?php
  2. /**
  3. * ArquivoForm Form
  4. * @author <your name here>
  5. */
  6. class ArquivoForm extends TPage
  7. {
  8. protected $form; // form
  9. private $formFields = [];
  10. private static $database = 'GestaoMedia';
  11. private static $activeRecord = 'Arquivo';
  12. private static $primaryKey = 'id';
  13. private static $formName = 'list_Arquivo';
  14. /**
  15. * Form constructor
  16. * @param $param Request
  17. */
  18. public function __construct( $param )
  19. {
  20. parent::__construct();
  21. // creates the form
  22. $this->form = new BootstrapFormBuilder(self::$formName);
  23. // define the form title
  24. $this->form->setFormTitle('Arquivo');
  25. $id = new TEntry('id');
  26. $ativo = new TRadioGroup('ativo');
  27. $cliente_id = new TDBCombo('cliente_id', 'GestaoMedia', 'Cliente', 'id', '{razao}','razao asc' );
  28. $titulo = new TEntry('titulo');
  29. $descricao = new TEntry('descricao');
  30. $data_hora_inicio = new TDateTime('data_hora_inicio');
  31. $data_hora_fim = new TDateTime('data_hora_fim');
  32. $segundos_tela = new TEntry('segundos_tela');
  33. $repeticoes = new TEntry('repeticoes');
  34. $data_envio = new TDateTime('data_envio');
  35. //$nome_arquivo = new TEntry('nome_arquivo');
  36. $nome_arquivo = new TFile('nome_arquivo');
  37. $nome_arquivo->setCompleteAction(new TAction(array($this, 'onComplete')));
  38. //$dispositivos = new TDBCheckGroup('dispositivos', 'GestaoMedia', 'Dispositivo', 'id', 'nome_dispositivo');
  39. //$dispositivos->setLayout('horizontal');
  40. //$dispositivos->setBreakItems(4);
  41. $ativo->addValidation('Ativo', new TRequiredValidator());
  42. $cliente_id->addValidation('Id do cliente', new TRequiredValidator());
  43. $titulo->addValidation('Titulo', new TRequiredValidator());
  44. $descricao->addValidation('Descrição', new TRequiredValidator());
  45. $data_hora_inicio->addValidation('Inicio da apresentação', new TRequiredValidator());
  46. $data_hora_fim->addValidation('Fim da apresentação', new TRequiredValidator());
  47. $segundos_tela->addValidation('Segundos na tela', new TRequiredValidator());
  48. $repeticoes->addValidation('Repetições', new TRequiredValidator());
  49. $nome_arquivo->addValidation('Nome do Arquivo', new TRequiredValidator());
  50. $data_envio->addValidation('Data de envio', new TRequiredValidator());
  51. $id->setEditable(false);
  52. $ativo->addItems(['1'=>'Sim','2'=>'Não']);
  53. $ativo->setLayout('horizontal');
  54. $ativo->setBooleanMode();
  55. $ativo->setValue('1');
  56. $segundos_tela->setValue('1');
  57. $titulo->forceUpperCase();
  58. $descricao->forceUpperCase();
  59. $nome_arquivo->forceUpperCase();
  60. $data_envio->setDatabaseMask('yyyy-mm-dd hh:ii');
  61. $data_envio->setEditable(false);
  62. $data_hora_fim->setDatabaseMask('yyyy-mm-dd hh:ii');
  63. $data_hora_inicio->setDatabaseMask('yyyy-mm-dd hh:ii');
  64. $repeticoes->setMask('99');
  65. $segundos_tela->setMask('999');
  66. $data_envio->setMask('dd/mm/yyyy hh:ii');
  67. $data_hora_fim->setMask('dd/mm/yyyy hh:ii');
  68. $data_hora_inicio->setMask('dd/mm/yyyy hh:ii');
  69. $id->setSize(92);
  70. $ativo->setSize(80);
  71. $titulo->setSize('100%');
  72. $data_envio->setSize(150);
  73. $descricao->setSize('100%');
  74. $cliente_id->setSize('100%');
  75. $data_hora_fim->setSize(150);
  76. $repeticoes->setSize('100%');
  77. $nome_arquivo->setSize('100%');
  78. $data_hora_inicio->setSize(150);
  79. $segundos_tela->setSize('100%');
  80. if (!empty($id))
  81. {
  82. $id->setEditable(FALSE);
  83. }
  84. $this->form->addFields([new TLabel('id:')],[$id],[new TLabel('Ativo:', '#ff0000')],[$ativo]);
  85. $this->form->addFields([new TLabel('Cliente:', '#ff0000')],[$cliente_id]);
  86. $this->form->addFields([new TLabel('Titulo:', '#ff0000')],[$titulo]);
  87. $this->form->addFields([new TLabel('Descrição:', '#ff0000')],[$descricao]);
  88. $this->form->addFields([new TLabel('Inicio da apresentação:', '#ff0000')],[$data_hora_inicio],[new TLabel('Fim da apresentação:', '#ff0000')],[$data_hora_fim]);
  89. $this->form->addFields([new TLabel('Segundos na tela:', '#ff0000')],[$segundos_tela],[new TLabel('Repetições:', '#ff0000')],[$repeticoes]);
  90. $this->form->addFields([new TLabel('Nome do Arquivo:', '#ff0000')],[$nome_arquivo]);
  91. $this->form->addFields([new TLabel('Data de envio:', '#ff0000')],[$data_envio]);
  92. $this->form->addContent([new TFormSeparator('Visualização do arquivo carregado', '#333333', '18', '#eeeeee')]);
  93. // Preview da imagem
  94. $this->frame = new TElement('div');
  95. $this->frame->id = 'photo_frame';
  96. $this->frame->style = 'width:400px;height:auto;min-height:200px;border:1px solid gray;padding:4px;margin:auto';
  97. $this->form->addContent([$this->frame]);
  98. $this->form->addContent([new TFormSeparator('Dispositivos onde o arquivo será exibido', '#333333', '18', '#eeeeee')]);
  99. // create the form actions
  100. $btn_onsave = $this->form->addAction('Salvar', new TAction([$this, 'onSave']), 'fa:floppy-o #ffffff');
  101. $btn_onsave->addStyleClass('btn-primary');
  102. $btn_onclear = $this->form->addAction('Limpar formulário', new TAction([$this, 'onClear']), 'fa:eraser #dd5a43');
  103. // vertical box container
  104. $container = new TVBox;
  105. $container->style = 'width: 100%';
  106. $container->class = 'form-container';
  107. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  108. $container->add($this->form);
  109. parent::add($container);
  110. }
  111. /**
  112. * On complete upload
  113. */
  114. public static function onComplete($param)
  115. {
  116. TScript::create("$('#photo_frame').html('')");
  117. TScript::create("$('#photo_frame').append(\"<img style='width:100%' src='tmp/{$param['nome_arquivo']}'>\");");
  118. // Tentativa de alterar a data de envio da imagem após fazer o carregamento
  119. //$data_envio->setValue(date("d-m-Y H:i"));
  120. /*
  121. Esse if é importante mas não está funcionando
  122. if ((strpos($param["nome_arquivo"],'.png')) && (strpos($param["nome_arquivo"],'.PNG')) && (strpos($param["nome_arquivo"],'.jpg')) && (strpos($param["nome_arquivo"],'.JPG'))){
  123. print_r($param["nome_arquivo"]);
  124. TScript::create("$('#photo_frame').html('')");
  125. TScript::create("$('#photo_frame').append(\"<img style='width:100%' src='tmp/{$param['nome_arquivo']}'>\");");
  126. }*/
  127. }
  128. public function onSave($param = null)
  129. {
  130. try
  131. {
  132. TTransaction::open(self::$database); // open a transaction
  133. /**
  134. // Enable Debug logger for SQL operations inside the transaction
  135. TTransaction::setLogger(new TLoggerSTD); // standard output
  136. TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  137. **/
  138. $messageAction = null;
  139. $this->form->validate(); // validate form data
  140. $object = new Arquivo(); // create an empty object
  141. $data = $this->form->getData(); // get form data as array
  142. $object->fromArray( (array) $data); // load the object with data
  143. $object->store(); // save the object
  144. if ($data->dispositivos)
  145. {
  146. foreach ($data->dispositivos as $dispositivo_id)
  147. {
  148. TTransaction::open('GestaoMedia');
  149. $dispositivo = Dispositivo::find($dispositivo_id);
  150. TTransaction::close();
  151. $object->addArquivoDispositivo( $dispositivo );
  152. }
  153. }
  154. $source_file = 'tmp/'.$object->nome_arquivo;
  155. //var_dump($source_file);
  156. $target_file = 'files/'.$object->id.'-'.$object->nome_arquivo;
  157. //var_dump($target_file);
  158. if (file_exists($source_file))
  159. {
  160. //new TMessage('info', 'O arquivo existe!');
  161. rename($source_file, $target_file);
  162. }
  163. // get the generated {PRIMARY_KEY}
  164. $data->id = $object->id;
  165. $this->form->setData($data); // fill form data
  166. TTransaction::close(); // close the transaction
  167. /**
  168. // To define an action to be executed on the message close event:
  169. $messageAction = new TAction(['className', 'methodName']);
  170. **/
  171. new TMessage('info', AdiantiCoreTranslator::translate('Record saved'), $messageAction);
  172. }
  173. catch (Exception $e) // in case of exception
  174. {
  175. new TMessage('error', $e->getMessage()); // shows the exception error message
  176. $this->form->setData( $this->form->getData() ); // keep form data
  177. TTransaction::rollback(); // undo all pending operations
  178. }
  179. }
  180. /**
  181. * Clear form data
  182. * @param $param Request
  183. */
  184. public function onClear( $param )
  185. {
  186. $this->form->clear();
  187. }
  188. public function onEdit( $param )
  189. {
  190. try
  191. {
  192. if (isset($param['key']))
  193. {
  194. $key = $param['key']; // get the parameter $key
  195. TTransaction::open(self::$database); // open a transaction
  196. $object = new Arquivo($key); // instantiates the Active Record
  197. $this->form->setData($object); // fill the form
  198. TTransaction::close(); // close the transaction
  199. }
  200. else
  201. {
  202. $this->form->clear();
  203. }
  204. }
  205. catch (Exception $e) // in case of exception
  206. {
  207. new TMessage('error', $e->getMessage()); // shows the exception error message
  208. TTransaction::rollback(); // undo all pending operations
  209. }
  210. }
  211. public function onShow()
  212. {
  213. }
  214. }
  215. ?>




Não estou conseguindo mudar o código para a mensagem sumir.
Vou anexar o arquivo de erro do php para dar mais detalhes.

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 (1)


NR

[07-Dec-2017 08:09:55 America/Sao_Paulo] PHP 5. AdiantiWidgetFormTFile->forceUpperCase() C:wamp64wwwgestaomediaappcontrolcadastrosArquivoForm.php:70

A função forceUpperCase não existe na classe TFile.