Exibir TImage no Form Galera, estou tentando exibir uma imagem armazenada no banco de dados, utilizando um método onChangeAction, consigo exibir a imagem utilizando um TMessage, porém, quero que ela fique em um campo no form. Segue meu código: ...
IC
Exibir TImage no Form  
Galera, estou tentando exibir uma imagem armazenada no banco de dados, utilizando um método onChangeAction, consigo exibir a imagem utilizando um TMessage, porém, quero que ela fique em um campo no form. Segue meu código:

  1. <?php
  2. class TrocaSolicitado extends TPage
  3. {
  4.     protected $form// form
  5.     
  6.     /**
  7.      * Class constructor
  8.      * Creates the page and the registration form
  9.      */
  10.     function __construct()
  11.     {
  12.         parent::__construct();
  13.         
  14.         // creates the form
  15.         $this->form = new BootstrapFormBuilder('form_troca_solicitado');
  16.         $this->form->setFormTitle('Solicitado');
  17.         
  18.         $SETOR      = new TEntry('SETOR');
  19.         $SETOR->setValue(TSession::getValue('SETOR'));
  20.         $MES_DA_ESCALA = new TEntry('MES_DA_ESCALA');
  21.         $MES_DA_ESCALA->setValue(TSession::getValue('MES_ESCALA'));
  22.         $NOME  = new TCombo('NOME');
  23.         $CPF = new TEntry('CPF');
  24.         $FOTO = new TImage('FOTO');
  25.         base64_encode($FOTO);
  26.       
  27.         $SETOR->setExitAction( new TAction( array($this'onExitAction') ) );
  28.         $CPF->setExitAction( new TAction( array($this'onFotoAction') ) );
  29.         $NOME->setChangeAction(new TAction([$this'onChangeAction']));
  30.         
  31.         
  32.        
  33.         // add the fields
  34.         $this->form->addFields(['SETOR: '], [$SETOR] );
  35.         $this->form->addFields(['MES DA ESCALA: '], [$MES_DA_ESCALA] );
  36.         $this->form->addFields(['NOME: '], [$NOME]);
  37.         $this->form->addFields(['CPF: '], [$CPF], ['FOTO'], [$FOTO]);
  38.        
  39.         
  40.         // validations
  41.         $NOME->addValidation('NOME: ', new TRequiredValidator);
  42.            
  43.         
  44.         $NOME->setSize('40%');
  45.         $MES_DA_ESCALA->setSize('40%');
  46.         $SETOR->setSize('40%');
  47.         $CPF->setSize('105%');
  48.          
  49.         $this->form->addAction('Next', new TAction(array($this'onConfirm')), 'far:check-circle green');
  50.         $this->form->addAction('Back', new TAction(array($this'onBackForm')), 'far:check-circle red');
  51.         
  52.         $pagestep = new TPageStep;
  53.         $pagestep->addItem('SOLICITACAO');
  54.         $pagestep->addItem('SETOR');
  55.         $pagestep->addItem('SOLICITADO');
  56.         $pagestep->addItem('CONFIRMAR');
  57.         $pagestep->select('SOLICITADO');
  58.         
  59.         // wrap the page content using vertical box
  60.         $vbox = new TVBox;
  61.         $vbox->style 'width: 100%';
  62.        // $vbox->add(new TXMLBreadCrumb('menu.xml', 'MultiStepRegistration1View'));
  63.         $vbox->add$pagestep );
  64.         $vbox->add$this->form );
  65.         parent::add($vbox);
  66.     }
  67.     
  68.        public static function onExitAction($param){
  69.          $SETOR $param['SETOR'];
  70.          $MES_DA_ESCALA $param['MES_DA_ESCALA'];
  71.          TTransaction::open('parametros_gente');
  72.          $servidores Escalas::select('NOME','CPF')->where('MES_DA_ESCALA''='$MES_DA_ESCALA)->where('SETOR''='$SETOR)->orderBy('NOME')
  73.          ->load();
  74.          $result = array();
  75.     
  76.           foreach ($servidores as $obj)
  77.         {     
  78.            $result[$obj->CPF] = $obj->NOME;
  79.         }
  80.         TCombo::reload('form_troca_solicitado''NOME'$result);
  81.    
  82.             TTransaction::close();  
  83.         }
  84.         
  85.         
  86.         
  87.         public static function onChangeAction($param)
  88.         {
  89.             @$NOME $param['NOME'];
  90.             TTransaction::open('pessoal');
  91.             $servidores Servidores::where('CPF''=',$NOME)->load();     
  92.             
  93.             $result = new stdClass;         
  94.             foreach($servidores as $obj)
  95.             {
  96.                 $result->CPF $obj->CPF;
  97.             }
  98.             
  99.             TForm::sendData('form_troca_solicitado'$result);
  100.             TTransaction::close();     
  101.         }
  102.         
  103.         public static function onFotoAction($param)
  104.         {
  105.          $CPF $param['CPF'];
  106.          TTransaction::open('pessoal');
  107.          $fotos ServidorFoto::where('SEQ_SERVIDOR','in',"(SELECT SEQ_SERVIDOR FROM SERVIDORES WHERE CPF = '$CPF' AND SERVIDORES.SEQ_SITUACAO = 46)")->load();
  108.          $resultfotos = new stdClass;
  109.        
  110.          foreach($fotos as $objfotos)
  111.          {
  112.             $resultfotos->FOTO = new TMessage('info''<img src="data:image/png;base64,' base64_encode($objfotos->FOTO) . '" />' );
  113.            
  114.             //TScript::create(($objfotos->FOTO)); 
  115.          }
  116.          
  117.          TForm::sendData('form_troca_solicitado'$resultfotos);
  118.          TTransaction::close();
  119.         }
  120.   
  121.  
  122.     
  123.     public function onBackForm()
  124.     {
  125.         // Load another page
  126.         AdiantiCoreApplication::loadPage('SetorTroca');
  127.     }
  128.     
  129.     /**
  130.      * confirmation screen
  131.      */
  132.     public function onConfirm()
  133.     {
  134.         try
  135.         {
  136.             $this->form->validate();
  137.             $data $this->form->getData();
  138.             TSession::setValue('registration_data', (array) $data);
  139.             TSession::setValue('NOMESOLICITADO'$data->NOME);
  140.             TSession::setValue('SETORSOLICITADO'$data->SETOR);
  141.             
  142.             AdiantiCoreApplication::loadPage('Confirmacao');
  143.         }
  144.         catch (Exception $e)
  145.         {
  146.             new TMessage('error'$e->getMessage());
  147.         }
  148.     }
  149.     
  150.  
  151. }
  152. ?>

Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto Quero me inscrever agora!

Comentários (2)


NR

Acho que usar javascript é mais fácil nesse caso, pois o TImage não é um input e com isso não é possível enviar informações via sendData/setData:
  1. <?php
  2. // construct
  3. $FOTO = new TImage('');
  4. $FOTO->id 'minhafoto';
  5. //onFotoAction
  6. $base64 base64_encode($objfotos->FOTO);
  7. TScript::create("$('#minhafoto').attr('src','data:image/png;base64,{$base64}');");
  8. ?>
IC

Nataniel, deu muito certo! Muito obrigado, brother! Agora só resta enquadra as imagens pra ficar certinho no form. Vlw mesmo!