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:
Não estou conseguindo mudar o código para a mensagem sumir.
Vou anexar o arquivo de erro do php para dar mais detalhes.
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:
- <?php
- <?php
- /**
- * ArquivoForm Form
- * @author <your name here>
- */
- class ArquivoForm extends TPage
- {
- protected $form; // form
- private $formFields = [];
- private static $database = 'GestaoMedia';
- private static $activeRecord = 'Arquivo';
- private static $primaryKey = 'id';
- private static $formName = 'list_Arquivo';
- /**
- * Form constructor
- * @param $param Request
- */
- public function __construct( $param )
- {
- parent::__construct();
- // creates the form
- $this->form = new BootstrapFormBuilder(self::$formName);
- // define the form title
- $this->form->setFormTitle('Arquivo');
- $id = new TEntry('id');
- $ativo = new TRadioGroup('ativo');
- $cliente_id = new TDBCombo('cliente_id', 'GestaoMedia', 'Cliente', 'id', '{razao}','razao asc' );
- $titulo = new TEntry('titulo');
- $descricao = new TEntry('descricao');
- $data_hora_inicio = new TDateTime('data_hora_inicio');
- $data_hora_fim = new TDateTime('data_hora_fim');
- $segundos_tela = new TEntry('segundos_tela');
- $repeticoes = new TEntry('repeticoes');
- $data_envio = new TDateTime('data_envio');
- //$nome_arquivo = new TEntry('nome_arquivo');
- $nome_arquivo = new TFile('nome_arquivo');
- $nome_arquivo->setCompleteAction(new TAction(array($this, 'onComplete')));
- //$dispositivos = new TDBCheckGroup('dispositivos', 'GestaoMedia', 'Dispositivo', 'id', 'nome_dispositivo');
- //$dispositivos->setLayout('horizontal');
- //$dispositivos->setBreakItems(4);
- $ativo->addValidation('Ativo', new TRequiredValidator());
- $cliente_id->addValidation('Id do cliente', new TRequiredValidator());
- $titulo->addValidation('Titulo', new TRequiredValidator());
- $descricao->addValidation('Descrição', new TRequiredValidator());
- $data_hora_inicio->addValidation('Inicio da apresentação', new TRequiredValidator());
- $data_hora_fim->addValidation('Fim da apresentação', new TRequiredValidator());
- $segundos_tela->addValidation('Segundos na tela', new TRequiredValidator());
- $repeticoes->addValidation('Repetições', new TRequiredValidator());
- $nome_arquivo->addValidation('Nome do Arquivo', new TRequiredValidator());
- $data_envio->addValidation('Data de envio', new TRequiredValidator());
- $id->setEditable(false);
- $ativo->addItems(['1'=>'Sim','2'=>'Não']);
- $ativo->setLayout('horizontal');
- $ativo->setBooleanMode();
- $ativo->setValue('1');
- $segundos_tela->setValue('1');
- $titulo->forceUpperCase();
- $descricao->forceUpperCase();
- $nome_arquivo->forceUpperCase();
- $data_envio->setDatabaseMask('yyyy-mm-dd hh:ii');
- $data_envio->setEditable(false);
- $data_hora_fim->setDatabaseMask('yyyy-mm-dd hh:ii');
- $data_hora_inicio->setDatabaseMask('yyyy-mm-dd hh:ii');
- $repeticoes->setMask('99');
- $segundos_tela->setMask('999');
- $data_envio->setMask('dd/mm/yyyy hh:ii');
- $data_hora_fim->setMask('dd/mm/yyyy hh:ii');
- $data_hora_inicio->setMask('dd/mm/yyyy hh:ii');
- $id->setSize(92);
- $ativo->setSize(80);
- $titulo->setSize('100%');
- $data_envio->setSize(150);
- $descricao->setSize('100%');
- $cliente_id->setSize('100%');
- $data_hora_fim->setSize(150);
- $repeticoes->setSize('100%');
- $nome_arquivo->setSize('100%');
- $data_hora_inicio->setSize(150);
- $segundos_tela->setSize('100%');
- if (!empty($id))
- {
- $id->setEditable(FALSE);
- }
- $this->form->addFields([new TLabel('id:')],[$id],[new TLabel('Ativo:', '#ff0000')],[$ativo]);
- $this->form->addFields([new TLabel('Cliente:', '#ff0000')],[$cliente_id]);
- $this->form->addFields([new TLabel('Titulo:', '#ff0000')],[$titulo]);
- $this->form->addFields([new TLabel('Descrição:', '#ff0000')],[$descricao]);
- $this->form->addFields([new TLabel('Inicio da apresentação:', '#ff0000')],[$data_hora_inicio],[new TLabel('Fim da apresentação:', '#ff0000')],[$data_hora_fim]);
- $this->form->addFields([new TLabel('Segundos na tela:', '#ff0000')],[$segundos_tela],[new TLabel('Repetições:', '#ff0000')],[$repeticoes]);
- $this->form->addFields([new TLabel('Nome do Arquivo:', '#ff0000')],[$nome_arquivo]);
- $this->form->addFields([new TLabel('Data de envio:', '#ff0000')],[$data_envio]);
- $this->form->addContent([new TFormSeparator('Visualização do arquivo carregado', '#333333', '18', '#eeeeee')]);
- // Preview da imagem
- $this->frame = new TElement('div');
- $this->frame->id = 'photo_frame';
- $this->frame->style = 'width:400px;height:auto;min-height:200px;border:1px solid gray;padding:4px;margin:auto';
- $this->form->addContent([$this->frame]);
- $this->form->addContent([new TFormSeparator('Dispositivos onde o arquivo será exibido', '#333333', '18', '#eeeeee')]);
- // create the form actions
- $btn_onsave = $this->form->addAction('Salvar', new TAction([$this, 'onSave']), 'fa:floppy-o #ffffff');
- $btn_onsave->addStyleClass('btn-primary');
- $btn_onclear = $this->form->addAction('Limpar formulário', new TAction([$this, 'onClear']), 'fa:eraser #dd5a43');
- // vertical box container
- $container = new TVBox;
- $container->style = 'width: 100%';
- $container->class = 'form-container';
- // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
- $container->add($this->form);
- parent::add($container);
- }
- /**
- * On complete upload
- */
- public static function onComplete($param)
- {
- TScript::create("$('#photo_frame').html('')");
- TScript::create("$('#photo_frame').append(\"<img style='width:100%' src='tmp/{$param['nome_arquivo']}'>\");");
- // Tentativa de alterar a data de envio da imagem após fazer o carregamento
- //$data_envio->setValue(date("d-m-Y H:i"));
- /*
- Esse if é importante mas não está funcionando
- if ((strpos($param["nome_arquivo"],'.png')) && (strpos($param["nome_arquivo"],'.PNG')) && (strpos($param["nome_arquivo"],'.jpg')) && (strpos($param["nome_arquivo"],'.JPG'))){
- print_r($param["nome_arquivo"]);
- TScript::create("$('#photo_frame').html('')");
- TScript::create("$('#photo_frame').append(\"<img style='width:100%' src='tmp/{$param['nome_arquivo']}'>\");");
- }*/
- }
- public function onSave($param = null)
- {
- try
- {
- TTransaction::open(self::$database); // open a transaction
- /**
- // Enable Debug logger for SQL operations inside the transaction
- TTransaction::setLogger(new TLoggerSTD); // standard output
- TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
- **/
- $messageAction = null;
- $this->form->validate(); // validate form data
- $object = new Arquivo(); // create an empty object
- $data = $this->form->getData(); // get form data as array
- $object->fromArray( (array) $data); // load the object with data
- $object->store(); // save the object
- if ($data->dispositivos)
- {
- foreach ($data->dispositivos as $dispositivo_id)
- {
- TTransaction::open('GestaoMedia');
- $dispositivo = Dispositivo::find($dispositivo_id);
- TTransaction::close();
- $object->addArquivoDispositivo( $dispositivo );
- }
- }
- $source_file = 'tmp/'.$object->nome_arquivo;
- //var_dump($source_file);
- $target_file = 'files/'.$object->id.'-'.$object->nome_arquivo;
- //var_dump($target_file);
- if (file_exists($source_file))
- {
- //new TMessage('info', 'O arquivo existe!');
- rename($source_file, $target_file);
- }
- // get the generated {PRIMARY_KEY}
- $data->id = $object->id;
- $this->form->setData($data); // fill form data
- TTransaction::close(); // close the transaction
- /**
- // To define an action to be executed on the message close event:
- $messageAction = new TAction(['className', 'methodName']);
- **/
- new TMessage('info', AdiantiCoreTranslator::translate('Record saved'), $messageAction);
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- $this->form->setData( $this->form->getData() ); // keep form data
- TTransaction::rollback(); // undo all pending operations
- }
- }
- /**
- * Clear form data
- * @param $param Request
- */
- public function onClear( $param )
- {
- $this->form->clear();
- }
- public function onEdit( $param )
- {
- try
- {
- if (isset($param['key']))
- {
- $key = $param['key']; // get the parameter $key
- TTransaction::open(self::$database); // open a transaction
- $object = new Arquivo($key); // instantiates the Active Record
- $this->form->setData($object); // fill the form
- TTransaction::close(); // close the transaction
- }
- else
- {
- $this->form->clear();
- }
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- TTransaction::rollback(); // undo all pending operations
- }
- }
- public function onShow()
- {
- }
- }
- ?>
Não estou conseguindo mudar o código para a mensagem sumir.
Vou anexar o arquivo de erro do php para dar mais detalhes.
[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.