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




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

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 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.