Lançado Adianti Framework 7.6!
Clique aqui para saber mais
evitar que onclean redirecione/recarregue o formulario em Modais e paginas em cortina lateral Boa tarde ! Gostaria de saber , como posso fazer pro metodo onClear não recarregar/redirecionar para outra pagina, quando eu estou em um Modal ou em uma pagina de cortina lateral . Já tentei de diversas formas, exemplos como : https://framework.adianti.me//tutor/index.php?class=SaleList e https://framework.adianti.me//tutor/index.php?class=CustomerDataGridView não mostram o cód...
FM
evitar que onclean redirecione/recarregue o formulario em Modais e paginas em cortina lateral  
Boa tarde !

Gostaria de saber , como posso fazer pro metodo onClear não recarregar/redirecionar para outra pagina, quando eu estou em um Modal ou em uma pagina de cortina lateral .

Já tentei de diversas formas, exemplos como :

https://framework.adianti.me//tutor/index.php?class=SaleList
e
https://framework.adianti.me//tutor/index.php?class=CustomerDataGridView

não mostram o código do da pagina em cortina, somente da index por trás .

Segue meu código



Formulário em questão :
  1. <?php 
  2. class DistribuidoraForm extends TPage
  3. {
  4.     private $form;
  5.     use Adianti\Base\AdiantiStandardFormTrait;
  6.     public function __construct($param)
  7.     {
  8.       parent::__construct();
  9.       $this->setDatabase('x');
  10.       $this->setActiveRecord('Distribuidora');
  11.       $this->form = new BootstrapFormBuilder('distribuidoraForm');
  12.       $this->form->setFormTitle(_t('Distributor'));
  13.       $this->form->setClientValidationtrue );
  14.       $this->form->setFieldSizes('100%');
  15.       $ID_DISTRIBUIDORA             = new TEntry('ID_DISTRIBUIDORA');
  16.       $ID_DISTRIBUIDORA->setEditable(FALSE);
  17.       $SIGLA                        = new TEntry('SIGLA');
  18.       $RAZAO_SOCIAL                 = new TEntry('RAZAO_SOCIAL');
  19.       $CNPJ                         = new TEntry('CNPJ');
  20.       $ID_SUBMERCADO = new TDBCombo('ID_SUBMERCADO','america_gestao','Submarket','ID_SUBMERCADO','SIGLA');
  21.       $DIA_REAJUSTE                 = new TEntry('DIA_REAJUSTE');  
  22.       $MES_REAJUSTE                 = new TEntry('MES_REAJUSTE');            
  23.         
  24.       $this->form->setFormTitle(_t('Distributor'));
  25.       $row $this->form->addFields( [ new TLabel('<b>'._t('Distributor code').'</b>'),   $ID_DISTRIBUIDORA ] );
  26.       $row->layout = ['col-md-12' ];
  27.       $row $this->form->addFields(
  28.                                       [new TLabel('<b>'._t('Initials').'</b>'), $SIGLA],
  29.                                       [new TLabel('<b>'._t('Corporate name').'</b>'), $RAZAO_SOCIAL],
  30.                                       [new TLabel('<b> CNPJ</b>'),   $CNPJ ],
  31.                                                                             
  32.                                     );
  33.       $row->layout = ['col-sm-4''col-sm-4''col-sm-4'];
  34.       $row $this->form->addFields(
  35.                                      [new TLabel('<b>'._t('Submarket').'</b>'), $ID_SUBMERCADO],
  36.                                      [new TLabel('<b>'._t('Readjustment day').'</b>'),   $DIA_REAJUSTE ],
  37.                                      [new TLabel('<b>'._t('Month of readjustmenty').'</b>'), $MES_REAJUSTE]
  38.                                    );
  39.      $row->layout = ['col-sm-4''col-sm-4''col-sm-4'];
  40.      $this->form->addAction('Salvar', new TAction( [$this'onSave'] ), 'fa:save green');
  41.      $this->form->addActionLink(_t('Back'),new TAction(array('DistribuidoraList','onReload')),'far:arrow-alt-circle-left blue');
  42.      $this->form->addActionLink('Limpar', new TAction( [$this'onClear']), 'fa:eraser red');
  43.      
  44.       parent::add($this->form);
  45.     }
  46.     public function onEdit$param )
  47.     {
  48.       try
  49.       {
  50.           TTransaction::open('america_gestao');
  51.           if ( isset( $param['ID_DISTRIBUIDORA'] ) )
  52.           {
  53.             $key $param['ID_DISTRIBUIDORA'];
  54.             $dist = new Distribuidora($key);
  55.             $dist->ID_ALTERADO_POR TSession::getValue('userid');
  56.             $dist->DT_ALTERADO_EM date('Y-m-d h:i:sa');
  57.             $this->form->setData($dist);
  58.           }
  59.           else
  60.           {
  61.             $this->form->clear();
  62.           }
  63.           TTransaction::close();
  64.       } catch (Exception $e)
  65.       {
  66.         new TMessage('error'$e->getMessage());
  67.         TTransaction::rollback();
  68.       }
  69.     }
  70.     public function cadastrarDist($param)
  71.     {
  72.         $this->form->onEdit($param);
  73.     }
  74.     public function onClear()
  75.     {
  76.       $this->form->clear();
  77.       
  78.     }
  79. ?>


método utilizado pra abrir em Modal / cortina lateral

  1. <?php 
  2. /**
  3.  * CustomerFormWindow Active Record
  4.  * 
  5.  */
  6. class DistribuidoraFormWindow extends TPage
  7. {
  8.     public function __construct($param)
  9.     {
  10.         
  11.         parent::__construct($param);
  12.         //parent::setSize(0.6, 0.6);
  13.         //parent::setMinWidth(1, 700);
  14.         //parent::removePadding();
  15.         //parent::disableEscape();
  16.         //parent::setTitle(_t('Register/edit distributor'));
  17.         $this->form = new DistribuidoraForm($paramtrue);
  18.         
  19.         //$this->form->setTargetContainer('');
  20.         parent::setTargetContainer('adianti_right_panel');
  21.         parent::add($this->form);
  22.     }
  23.     
  24.     /**
  25.      * Redirect calls to decorated object
  26.      */
  27.     public function cadastrarDist($param)
  28.     {
  29.         $this->form->onEdit($param);
  30.     }
  31. }
  32. ?>


botao utilizado pra chamar a janela

  1. <?php 
  2.         $button = new TActionLink('', new TAction(['DistribuidoraFormWindow''cadastrarDist'],['ID_DISTRIBUIDORA' => $id_modal_dist  'register_state' => 'false']), 'green'nullnull'fa:plus-circle');
  3. ?>
Editado 05/05/2022 (há 1 ano) - Clique para ver alterações

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


NR

Acredito que a forma mais fácil seja fazer isso estaticamente, ou seja, sem recarga de tela. Ex:
  1. <?php
  2. public static function onClear($param)
  3. {
  4.       $dados_form = [
  5.           'ID_DISTRIBUIDORA' => ''
  6.           'SIGLA' => '',
  7.           'RAZAO_SOCIAL' => '',
  8.           'CNPJ' => ''
  9.           'ID_SUBMERCADO' => '',
  10.           'DIA_REAJUSTE' => ''
  11.           'MES_REAJUSTE' => ''
  12.      ];
  13.      TForm::sendData('distribuidoraForm', (object) $dados_form);
  14. }
  15. ?>