Lançado Adianti Framework 8.1!
Clique aqui para saber mais
erro ao gerar formulario de consulta no studio estou tendo este erro ao gerar formulario automatico de consulta no adianti, alguma sugestão? agradeço muito...
FR
erro ao gerar formulario de consulta no studio  
estou tendo este erro ao gerar formulario automatico de consulta no adianti, alguma sugestão? agradeço muito

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


MG

Felipe
O erro está dizendo que não existe o método onEdit no form gerado.
O form ´é "Grabovo1form". está correto?
FR

boa tarde, estou gerando ele automaticamente atraves de um formulario de cadastro. cara nunca deu esse erro...rssss
MG

Quando usamos o Studio para criar um "list", eme sugere o form com o mesmo nome.
Se por acaso o nome. Checou se o nome do form está correto?:

List->Form (onEdit).

As vezes um dígito errado no momento da criação ou correção depois de criado, é preciso fazer o ajuste manual.

Mas ainda está com error? Post o código para podermos ajudar!
FR

obrigado pela ajuda meu amigo, sim estou com erro ainda, segue codigo do form e do view , cara derrepente é algo besta...kkkk

  1. <?php
  2. class GrabovoiForm extends TPage
  3. {
  4.     protected $form// form
  5.     
  6.     /**
  7.      * Form constructor
  8.      * @param $param Request
  9.      */
  10.     public function __construct$param )
  11.     {
  12.         parent::__construct();
  13.         
  14.         
  15.         // creates the form
  16.         $this->form = new BootstrapFormBuilder('form_Grabovoi');
  17.         $this->form->setFormTitle('Grabovoi');
  18.         
  19.         // create the form fields
  20.         $id = new TEntry('id');
  21.         $nome = new TEntry('nome');
  22.         $numero = new TEntry('numero');
  23.         // add the fields
  24.         $this->form->addFields( [ new TLabel('Id') ], [ $id ] );
  25.         $this->form->addFields( [ new TLabel('Nome') ], [ $nome ] );
  26.         $this->form->addFields( [ new TLabel('Numero') ], [ $numero ] );
  27.         // set sizes
  28.         $id->setSize('100%');
  29.         $nome->setSize('100%');
  30.         $numero->setSize('100%');
  31.         if (!empty($id))
  32.         {
  33.             $id->setEditable(FALSE);
  34.         }
  35.         
  36.         /** samples
  37.          $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  38.          $fieldX->setSize( '100%' ); // set size
  39.          **/
  40.          
  41.         // create the form actions
  42.         $btn $this->form->addAction(_t('Save'), new TAction([$this'onSave']), 'fa:save');
  43.         $btn->class 'btn btn-sm btn-primary';
  44.         $this->form->addActionLink(_t('New'),  new TAction([$this'onEdit']), 'fa:eraser red');
  45.         
  46.         // vertical box container
  47.         $container = new TVBox;
  48.         $container->style 'width: 100%';
  49.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  50.         $container->add($this->form);
  51.         
  52.         parent::add($container);
  53.     }
  54.     /**
  55.      * Save form data
  56.      * @param $param Request
  57.      */
  58.     public function onSave$param )
  59.     {
  60.         try
  61.         {
  62.             TTransaction::open('grabovoi'); // open a transaction
  63.             
  64.             /**
  65.             // Enable Debug logger for SQL operations inside the transaction
  66.             TTransaction::setLogger(new TLoggerSTD); // standard output
  67.             TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  68.             **/
  69.             
  70.             $this->form->validate(); // validate form data
  71.             $data $this->form->getData(); // get form data as array
  72.             
  73.             $object = new Grabovoi;  // create an empty object
  74.             $object->fromArray( (array) $data); // load the object with data
  75.             $object->store(); // save the object
  76.             
  77.             // get the generated id
  78.             $data->id $object->id;
  79.             
  80.             $this->form->setData($data); // fill form data
  81.             TTransaction::close(); // close the transaction
  82.             
  83.             new TMessage('info'AdiantiCoreTranslator::translate('Record saved'));
  84.         }
  85.         catch (Exception $e// in case of exception
  86.         {
  87.             new TMessage('error'$e->getMessage()); // shows the exception error message
  88.             $this->form->setData$this->form->getData() ); // keep form data
  89.             TTransaction::rollback(); // undo all pending operations
  90.         }
  91.     }
  92.     
  93.     /**
  94.      * Clear form data
  95.      * @param $param Request
  96.      */
  97.     public function onClear$param )
  98.     {
  99.         $this->form->clear(TRUE);
  100.     }
  101.     
  102.     /**
  103.      * Load object to form data
  104.      * @param $param Request
  105.      */
  106.     public function onEdit$param )
  107.     {
  108.         try
  109.         {
  110.             if (isset($param['key']))
  111.             {
  112.                 $key $param['key'];  // get the parameter $key
  113.                 TTransaction::open('grabovoi'); // open a transaction
  114.                 $object = new Grabovoi($key); // instantiates the Active Record
  115.                 $this->form->setData($object); // fill the form
  116.                 TTransaction::close(); // close the transaction
  117.             }
  118.             else
  119.             {
  120.                 $this->form->clear(TRUE);
  121.             }
  122.         }
  123.         catch (Exception $e// in case of exception
  124.         {
  125.             new TMessage('error'$e->getMessage()); // shows the exception error message
  126.             TTransaction::rollback(); // undo all pending operations
  127.         }
  128.     }
  129. }
FR

obrigado pela ajuda meu amigo, sim estou com erro ainda, segue codigo do form e do view , cara derrepente é algo besta...kkkk

  1. <?php
  2. class GrabovoiForm extends TPage
  3. {
  4.     protected $form// form
  5.     
  6.     /**
  7.      * Form constructor
  8.      * @param $param Request
  9.      */
  10.     public function __construct$param )
  11.     {
  12.         parent::__construct();
  13.         
  14.         
  15.         // creates the form
  16.         $this->form = new BootstrapFormBuilder('form_Grabovoi');
  17.         $this->form->setFormTitle('Grabovoi');
  18.         
  19.         // create the form fields
  20.         $id = new TEntry('id');
  21.         $nome = new TEntry('nome');
  22.         $numero = new TEntry('numero');
  23.         // add the fields
  24.         $this->form->addFields( [ new TLabel('Id') ], [ $id ] );
  25.         $this->form->addFields( [ new TLabel('Nome') ], [ $nome ] );
  26.         $this->form->addFields( [ new TLabel('Numero') ], [ $numero ] );
  27.         // set sizes
  28.         $id->setSize('100%');
  29.         $nome->setSize('100%');
  30.         $numero->setSize('100%');
  31.         if (!empty($id))
  32.         {
  33.             $id->setEditable(FALSE);
  34.         }
  35.         
  36.         /** samples
  37.          $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  38.          $fieldX->setSize( '100%' ); // set size
  39.          **/
  40.          
  41.         // create the form actions
  42.         $btn $this->form->addAction(_t('Save'), new TAction([$this'onSave']), 'fa:save');
  43.         $btn->class 'btn btn-sm btn-primary';
  44.         $this->form->addActionLink(_t('New'),  new TAction([$this'onEdit']), 'fa:eraser red');
  45.         
  46.         // vertical box container
  47.         $container = new TVBox;
  48.         $container->style 'width: 100%';
  49.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  50.         $container->add($this->form);
  51.         
  52.         parent::add($container);
  53.     }
  54.     /**
  55.      * Save form data
  56.      * @param $param Request
  57.      */
  58.     public function onSave$param )
  59.     {
  60.         try
  61.         {
  62.             TTransaction::open('grabovoi'); // open a transaction
  63.             
  64.             /**
  65.             // Enable Debug logger for SQL operations inside the transaction
  66.             TTransaction::setLogger(new TLoggerSTD); // standard output
  67.             TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  68.             **/
  69.             
  70.             $this->form->validate(); // validate form data
  71.             $data $this->form->getData(); // get form data as array
  72.             
  73.             $object = new Grabovoi;  // create an empty object
  74.             $object->fromArray( (array) $data); // load the object with data
  75.             $object->store(); // save the object
  76.             
  77.             // get the generated id
  78.             $data->id $object->id;
  79.             
  80.             $this->form->setData($data); // fill form data
  81.             TTransaction::close(); // close the transaction
  82.             
  83.             new TMessage('info'AdiantiCoreTranslator::translate('Record saved'));
  84.         }
  85.         catch (Exception $e// in case of exception
  86.         {
  87.             new TMessage('error'$e->getMessage()); // shows the exception error message
  88.             $this->form->setData$this->form->getData() ); // keep form data
  89.             TTransaction::rollback(); // undo all pending operations
  90.         }
  91.     }
  92.     
  93.     /**
  94.      * Clear form data
  95.      * @param $param Request
  96.      */
  97.     public function onClear$param )
  98.     {
  99.         $this->form->clear(TRUE);
  100.     }
  101.     
  102.     /**
  103.      * Load object to form data
  104.      * @param $param Request
  105.      */
  106.     public function onEdit$param )
  107.     {
  108.         try
  109.         {
  110.             if (isset($param['key']))
  111.             {
  112.                 $key $param['key'];  // get the parameter $key
  113.                 TTransaction::open('grabovoi'); // open a transaction
  114.                 $object = new Grabovoi($key); // instantiates the Active Record
  115.                 $this->form->setData($object); // fill the form
  116.                 TTransaction::close(); // close the transaction
  117.             }
  118.             else
  119.             {
  120.                 $this->form->clear(TRUE);
  121.             }
  122.         }
  123.         catch (Exception $e// in case of exception
  124.         {
  125.             new TMessage('error'$e->getMessage()); // shows the exception error message
  126.             TTransaction::rollback(); // undo all pending operations
  127.         }
  128.     }
  129. }
FR

e o codigo do view, acima repetiu o form desculpa.

  1. <?php
  2. /**
  3.  * GrabovoiFormView Form
  4.  * @author  <your name here>
  5.  */
  6. class GrabovoiFormView extends TPage
  7. {
  8.     /**
  9.      * Form constructor
  10.      * @param $param Request
  11.      */
  12.     public function __construct$param )
  13.     {
  14.         parent::__construct();
  15.         
  16.         
  17.         $this->form = new BootstrapFormBuilder('form_Grabovoi_View');
  18.         
  19.         $this->form->setFormTitle('Grabovoi');
  20.         $this->form->setColumnClasses(2, ['col-sm-3''col-sm-9']);
  21.         $this->form->addHeaderActionLink_t('Print'), new TAction([$this'onPrint'], ['key'=>$param['key'], 'static' => '1']), 'far:file-pdf red');
  22.         $this->form->addHeaderActionLink_t('Edit'), new TAction(['GrabovoiForm''onEdit'], ['key'=>$param['key'], 'register_state'=>'true']), 'far:edit blue');
  23.         
  24.         // vertical box container
  25.         $container = new TVBox;
  26.         $container->style 'width: 100%';
  27.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  28.         $container->add($this->form);
  29.         parent::add($container);
  30.     }
  31.     
  32.     /**
  33.      * Show data
  34.      */
  35.     public function onEdit$param )
  36.     {
  37.         try
  38.         {
  39.             TTransaction::open('grabovoi');
  40.         
  41.             $object = new Grabovoi($param['key']);
  42.             
  43.             $label_id = new TLabel('Id:''#333333''''B');
  44.             $label_nome = new TLabel('Nome:''#333333''''B');
  45.             $label_numero = new TLabel('Numero:''#333333''''B');
  46.             $text_id  = new TTextDisplay($object->id'#333333''''');
  47.             $text_nome  = new TTextDisplay($object->nome'#333333''''');
  48.             $text_numero  = new TTextDisplay($object->numero'#333333''''');
  49.             $this->form->addFields([$label_id],[$text_id]);
  50.             $this->form->addFields([$label_nome],[$text_nome]);
  51.             $this->form->addFields([$label_numero],[$text_numero]);
  52.             TTransaction::close();
  53.         }
  54.         catch (Exception $e)
  55.         {
  56.             new TMessage('error'$e->getMessage());
  57.         }
  58.     }
  59.     
  60.     /**
  61.      * Print view
  62.      */
  63.     public function onPrint($param)
  64.     {
  65.         try
  66.         {
  67.             $this->onEdit($param);
  68.             
  69.             // string with HTML contents
  70.             $html = clone $this->form;
  71.             $contents file_get_contents('app/resources/styles-print.html') . $html->getContents();
  72.             
  73.             // converts the HTML template into PDF
  74.             $dompdf = new \Dompdf\Dompdf();
  75.             $dompdf->loadHtml($contents);
  76.             $dompdf->setPaper('A4''portrait');
  77.             $dompdf->render();
  78.             
  79.             $file 'app/output/Grabovoi-export.pdf';
  80.             
  81.             // write and open file
  82.             file_put_contents($file$dompdf->output());
  83.             
  84.             $window TWindow::create('Export'0.80.8);
  85.             $object = new TElement('object');
  86.             $object->data  $file.'?rndval='.uniqid();
  87.             $object->type  'application/pdf';
  88.             $object->style "width: 100%; height:calc(100% - 10px)";
  89.             $window->add($object);
  90.             $window->show();
  91.         }
  92.         catch (Exception $e)
  93.         {
  94.             new TMessage('error'$e->getMessage());
  95.         }
  96.     }
  97. }
  98. </your>
MG

Felipe

Observe que a exception faz referência à classe GrabovoiForm1. Pelo que vi o correto é GrabovoiForm

Onde você chama este formulário? É do menu?

Retire o 1 da url e tente novamente!
FR

bom dia, então! o que fiz... exclui os arquivos e comecei tudo de novo, o grande lance é que em qualquer projeto com banco que eu vá gerar estou tendo erro só no form view, ou tem algo errado ou desaprendi...rs esses que te colei exclui ontem a noite ai comecei tudo do zero...vou colar de novo aqui , criei arquivos com outros nomes.

este é o form

  1. <?php
  2. /**
  3.  * GrabovoiForm1 Form
  4.  * @author  <your name here>
  5.  */
  6. class GrabovoiForm1 extends TPage
  7. {
  8.     protected $form// form
  9.     
  10.     /**
  11.      * Form constructor
  12.      * @param $param Request
  13.      */
  14.     public function __construct$param )
  15.     {
  16.         parent::__construct();
  17.         
  18.         
  19.         // creates the form
  20.         $this->form = new BootstrapFormBuilder('form_Grabovoi');
  21.         $this->form->setFormTitle('Grabovoi');
  22.         
  23.         // create the form fields
  24.         $id = new TEntry('id');
  25.         $nome = new TEntry('nome');
  26.         $numero = new TEntry('numero');
  27.         // add the fields
  28.         $this->form->addFields( [ new TLabel('Id') ], [ $id ] );
  29.         $this->form->addFields( [ new TLabel('Nome') ], [ $nome ] );
  30.         $this->form->addFields( [ new TLabel('Numero') ], [ $numero ] );
  31.         // set sizes
  32.         $id->setSize('100%');
  33.         $nome->setSize('100%');
  34.         $numero->setSize('100%');
  35.         if (!empty($id))
  36.         {
  37.             $id->setEditable(FALSE);
  38.         }
  39.         
  40.         /** samples
  41.          $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  42.          $fieldX->setSize( '100%' ); // set size
  43.          **/
  44.          
  45.         // create the form actions
  46.         $btn $this->form->addAction(_t('Save'), new TAction([$this'onSave']), 'fa:save');
  47.         $btn->class 'btn btn-sm btn-primary';
  48.         $this->form->addActionLink(_t('New'),  new TAction([$this'onEdit']), 'fa:eraser red');
  49.         
  50.         // vertical box container
  51.         $container = new TVBox;
  52.         $container->style 'width: 100%';
  53.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  54.         $container->add($this->form);
  55.         
  56.         parent::add($container);
  57.     }
  58.     /**
  59.      * Save form data
  60.      * @param $param Request
  61.      */
  62.     public function onSave$param )
  63.     {
  64.         try
  65.         {
  66.             TTransaction::open('grabovoi'); // open a transaction
  67.             
  68.             /**
  69.             // Enable Debug logger for SQL operations inside the transaction
  70.             TTransaction::setLogger(new TLoggerSTD); // standard output
  71.             TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  72.             **/
  73.             
  74.             $this->form->validate(); // validate form data
  75.             $data $this->form->getData(); // get form data as array
  76.             
  77.             $object = new Grabovoi;  // create an empty object
  78.             $object->fromArray( (array) $data); // load the object with data
  79.             $object->store(); // save the object
  80.             
  81.             // get the generated id
  82.             $data->id $object->id;
  83.             
  84.             $this->form->setData($data); // fill form data
  85.             TTransaction::close(); // close the transaction
  86.             
  87.             new TMessage('info'AdiantiCoreTranslator::translate('Record saved'));
  88.         }
  89.         catch (Exception $e// in case of exception
  90.         {
  91.             new TMessage('error'$e->getMessage()); // shows the exception error message
  92.             $this->form->setData$this->form->getData() ); // keep form data
  93.             TTransaction::rollback(); // undo all pending operations
  94.         }
  95.     }
  96.     
  97.     /**
  98.      * Clear form data
  99.      * @param $param Request
  100.      */
  101.     public function onClear$param )
  102.     {
  103.         $this->form->clear(TRUE);
  104.     }
  105.     
  106.     /**
  107.      * Load object to form data
  108.      * @param $param Request
  109.      */
  110.     public function onEdit$param )
  111.     {
  112.         try
  113.         {
  114.             if (isset($param['key']))
  115.             {
  116.                 $key $param['key'];  // get the parameter $key
  117.                 TTransaction::open('grabovoi'); // open a transaction
  118.                 $object = new Grabovoi($key); // instantiates the Active Record
  119.                 $this->form->setData($object); // fill the form
  120.                 TTransaction::close(); // close the transaction
  121.             }
  122.             else
  123.             {
  124.                 $this->form->clear(TRUE);
  125.             }
  126.         }
  127.         catch (Exception $e// in case of exception
  128.         {
  129.             new TMessage('error'$e->getMessage()); // shows the exception error message
  130.             TTransaction::rollback(); // undo all pending operations
  131.         }
  132.     }
  133. }
  134. </your>
FR

este é o form view

  1. <?php
  2. /**
  3.  * GrabovoiFormView1 Form
  4.  * @author  <your name here>
  5.  */
  6. class GrabovoiFormView1 extends TPage
  7. {
  8.     /**
  9.      * Form constructor
  10.      * @param $param Request
  11.      */
  12.     public function __construct$param )
  13.     {
  14.         parent::__construct();
  15.         
  16.         
  17.         $this->form = new BootstrapFormBuilder('form_Grabovoi_View');
  18.         
  19.         $this->form->setFormTitle('Grabovoi');
  20.         $this->form->setColumnClasses(2, ['col-sm-3''col-sm-9']);
  21.         $this->form->addHeaderActionLink_t('Print'), new TAction([$this'onPrint'], ['key'=>$param['key'], 'static' => '1']), 'far:file-pdf red');
  22.         $this->form->addHeaderActionLink_t('Edit'), new TAction(['GrabovoiForm1''onEdit'], ['key'=>$param['key'], 'register_state'=>'true']), 'far:edit blue');
  23.         
  24.         // vertical box container
  25.         $container = new TVBox;
  26.         $container->style 'width: 100%';
  27.         // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  28.         $container->add($this->form);
  29.         parent::add($container);
  30.     }
  31.     
  32.     /**
  33.      * Show data
  34.      */
  35.     public function onEdit$param )
  36.     {
  37.         try
  38.         {
  39.             TTransaction::open('grabovoi');
  40.         
  41.             $object = new Grabovoi($param['key']);
  42.             
  43.             $label_id = new TLabel('Id:''#333333''''B');
  44.             $label_nome = new TLabel('Nome:''#333333''''B');
  45.             $label_numero = new TLabel('Numero:''#333333''''B');
  46.             $text_id  = new TTextDisplay($object->id'#333333''''');
  47.             $text_nome  = new TTextDisplay($object->nome'#333333''''');
  48.             $text_numero  = new TTextDisplay($object->numero'#333333''''');
  49.             $this->form->addFields([$label_id],[$text_id]);
  50.             $this->form->addFields([$label_nome],[$text_nome]);
  51.             $this->form->addFields([$label_numero],[$text_numero]);
  52.             TTransaction::close();
  53.         }
  54.         catch (Exception $e)
  55.         {
  56.             new TMessage('error'$e->getMessage());
  57.         }
  58.     }
  59.     
  60.     /**
  61.      * Print view
  62.      */
  63.     public function onPrint($param)
  64.     {
  65.         try
  66.         {
  67.             $this->onEdit($param);
  68.             
  69.             // string with HTML contents
  70.             $html = clone $this->form;
  71.             $contents file_get_contents('app/resources/styles-print.html') . $html->getContents();
  72.             
  73.             // converts the HTML template into PDF
  74.             $dompdf = new \Dompdf\Dompdf();
  75.             $dompdf->loadHtml($contents);
  76.             $dompdf->setPaper('A4''portrait');
  77.             $dompdf->render();
  78.             
  79.             $file 'app/output/Grabovoi-export.pdf';
  80.             
  81.             // write and open file
  82.             file_put_contents($file$dompdf->output());
  83.             
  84.             $window TWindow::create('Export'0.80.8);
  85.             $object = new TElement('object');
  86.             $object->data  $file.'?rndval='.uniqid();
  87.             $object->type  'application/pdf';
  88.             $object->style "width: 100%; height:calc(100% - 10px)";
  89.             $window->add($object);
  90.             $window->show();
  91.         }
  92.         catch (Exception $e)
  93.         {
  94.             new TMessage('error'$e->getMessage());
  95.         }
  96.     }
  97. }
  98. </your>
MG

Felipe
Realmente está estranho, pois os caminhos estão corretos!
Mas uma pergunta: Por que um formview chamando um form?
Não seria uma list chamando um form?
Observe que vc tem onEdit em ambos os forms.
FR

eu fiz isso, acabei de fazer usei uma list, estava pensando em criar algo que tinha na cabeça, porém consegui resolver com a list mesmo. meu amigo agradeço muito sua atenção. um grande abraço!!!
FR

eu fiz isso, acabei de fazer usei uma list, estava pensando em criar algo que tinha na cabeça, porém consegui resolver com a list mesmo. meu amigo agradeço muito sua atenção. um grande abraço!!!
FR

eu fiz isso, acabei de fazer usei uma list, estava pensando em criar algo que tinha na cabeça, porém consegui resolver com a list mesmo. meu amigo agradeço muito sua atenção. um grande abraço!!!