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. * Form constructor
  7. * @param $param Request
  8. */
  9. public function __construct( $param )
  10. {
  11. parent::__construct();
  12. // creates the form
  13. $this->form = new BootstrapFormBuilder('form_Grabovoi');
  14. $this->form->setFormTitle('Grabovoi');
  15. // create the form fields
  16. $id = new TEntry('id');
  17. $nome = new TEntry('nome');
  18. $numero = new TEntry('numero');
  19. // add the fields
  20. $this->form->addFields( [ new TLabel('Id') ], [ $id ] );
  21. $this->form->addFields( [ new TLabel('Nome') ], [ $nome ] );
  22. $this->form->addFields( [ new TLabel('Numero') ], [ $numero ] );
  23. // set sizes
  24. $id->setSize('100%');
  25. $nome->setSize('100%');
  26. $numero->setSize('100%');
  27. if (!empty($id))
  28. {
  29. $id->setEditable(FALSE);
  30. }
  31. /** samples
  32. $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  33. $fieldX->setSize( '100%' ); // set size
  34. **/
  35. // create the form actions
  36. $btn = $this->form->addAction(_t('Save'), new TAction([$this, 'onSave']), 'fa:save');
  37. $btn->class = 'btn btn-sm btn-primary';
  38. $this->form->addActionLink(_t('New'), new TAction([$this, 'onEdit']), 'fa:eraser red');
  39. // vertical box container
  40. $container = new TVBox;
  41. $container->style = 'width: 100%';
  42. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  43. $container->add($this->form);
  44. parent::add($container);
  45. }
  46. /**
  47. * Save form data
  48. * @param $param Request
  49. */
  50. public function onSave( $param )
  51. {
  52. try
  53. {
  54. TTransaction::open('grabovoi'); // open a transaction
  55. /**
  56. // Enable Debug logger for SQL operations inside the transaction
  57. TTransaction::setLogger(new TLoggerSTD); // standard output
  58. TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  59. **/
  60. $this->form->validate(); // validate form data
  61. $data = $this->form->getData(); // get form data as array
  62. $object = new Grabovoi; // create an empty object
  63. $object->fromArray( (array) $data); // load the object with data
  64. $object->store(); // save the object
  65. // get the generated id
  66. $data->id = $object->id;
  67. $this->form->setData($data); // fill form data
  68. TTransaction::close(); // close the transaction
  69. new TMessage('info', AdiantiCoreTranslator::translate('Record saved'));
  70. }
  71. catch (Exception $e) // in case of exception
  72. {
  73. new TMessage('error', $e->getMessage()); // shows the exception error message
  74. $this->form->setData( $this->form->getData() ); // keep form data
  75. TTransaction::rollback(); // undo all pending operations
  76. }
  77. }
  78. /**
  79. * Clear form data
  80. * @param $param Request
  81. */
  82. public function onClear( $param )
  83. {
  84. $this->form->clear(TRUE);
  85. }
  86. /**
  87. * Load object to form data
  88. * @param $param Request
  89. */
  90. public function onEdit( $param )
  91. {
  92. try
  93. {
  94. if (isset($param['key']))
  95. {
  96. $key = $param['key']; // get the parameter $key
  97. TTransaction::open('grabovoi'); // open a transaction
  98. $object = new Grabovoi($key); // instantiates the Active Record
  99. $this->form->setData($object); // fill the form
  100. TTransaction::close(); // close the transaction
  101. }
  102. else
  103. {
  104. $this->form->clear(TRUE);
  105. }
  106. }
  107. catch (Exception $e) // in case of exception
  108. {
  109. new TMessage('error', $e->getMessage()); // shows the exception error message
  110. TTransaction::rollback(); // undo all pending operations
  111. }
  112. }
  113. }
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. * Form constructor
  7. * @param $param Request
  8. */
  9. public function __construct( $param )
  10. {
  11. parent::__construct();
  12. // creates the form
  13. $this->form = new BootstrapFormBuilder('form_Grabovoi');
  14. $this->form->setFormTitle('Grabovoi');
  15. // create the form fields
  16. $id = new TEntry('id');
  17. $nome = new TEntry('nome');
  18. $numero = new TEntry('numero');
  19. // add the fields
  20. $this->form->addFields( [ new TLabel('Id') ], [ $id ] );
  21. $this->form->addFields( [ new TLabel('Nome') ], [ $nome ] );
  22. $this->form->addFields( [ new TLabel('Numero') ], [ $numero ] );
  23. // set sizes
  24. $id->setSize('100%');
  25. $nome->setSize('100%');
  26. $numero->setSize('100%');
  27. if (!empty($id))
  28. {
  29. $id->setEditable(FALSE);
  30. }
  31. /** samples
  32. $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  33. $fieldX->setSize( '100%' ); // set size
  34. **/
  35. // create the form actions
  36. $btn = $this->form->addAction(_t('Save'), new TAction([$this, 'onSave']), 'fa:save');
  37. $btn->class = 'btn btn-sm btn-primary';
  38. $this->form->addActionLink(_t('New'), new TAction([$this, 'onEdit']), 'fa:eraser red');
  39. // vertical box container
  40. $container = new TVBox;
  41. $container->style = 'width: 100%';
  42. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  43. $container->add($this->form);
  44. parent::add($container);
  45. }
  46. /**
  47. * Save form data
  48. * @param $param Request
  49. */
  50. public function onSave( $param )
  51. {
  52. try
  53. {
  54. TTransaction::open('grabovoi'); // open a transaction
  55. /**
  56. // Enable Debug logger for SQL operations inside the transaction
  57. TTransaction::setLogger(new TLoggerSTD); // standard output
  58. TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  59. **/
  60. $this->form->validate(); // validate form data
  61. $data = $this->form->getData(); // get form data as array
  62. $object = new Grabovoi; // create an empty object
  63. $object->fromArray( (array) $data); // load the object with data
  64. $object->store(); // save the object
  65. // get the generated id
  66. $data->id = $object->id;
  67. $this->form->setData($data); // fill form data
  68. TTransaction::close(); // close the transaction
  69. new TMessage('info', AdiantiCoreTranslator::translate('Record saved'));
  70. }
  71. catch (Exception $e) // in case of exception
  72. {
  73. new TMessage('error', $e->getMessage()); // shows the exception error message
  74. $this->form->setData( $this->form->getData() ); // keep form data
  75. TTransaction::rollback(); // undo all pending operations
  76. }
  77. }
  78. /**
  79. * Clear form data
  80. * @param $param Request
  81. */
  82. public function onClear( $param )
  83. {
  84. $this->form->clear(TRUE);
  85. }
  86. /**
  87. * Load object to form data
  88. * @param $param Request
  89. */
  90. public function onEdit( $param )
  91. {
  92. try
  93. {
  94. if (isset($param['key']))
  95. {
  96. $key = $param['key']; // get the parameter $key
  97. TTransaction::open('grabovoi'); // open a transaction
  98. $object = new Grabovoi($key); // instantiates the Active Record
  99. $this->form->setData($object); // fill the form
  100. TTransaction::close(); // close the transaction
  101. }
  102. else
  103. {
  104. $this->form->clear(TRUE);
  105. }
  106. }
  107. catch (Exception $e) // in case of exception
  108. {
  109. new TMessage('error', $e->getMessage()); // shows the exception error message
  110. TTransaction::rollback(); // undo all pending operations
  111. }
  112. }
  113. }
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. $this->form = new BootstrapFormBuilder('form_Grabovoi_View');
  16. $this->form->setFormTitle('Grabovoi');
  17. $this->form->setColumnClasses(2, ['col-sm-3', 'col-sm-9']);
  18. $this->form->addHeaderActionLink( _t('Print'), new TAction([$this, 'onPrint'], ['key'=>$param['key'], 'static' => '1']), 'far:file-pdf red');
  19. $this->form->addHeaderActionLink( _t('Edit'), new TAction(['GrabovoiForm', 'onEdit'], ['key'=>$param['key'], 'register_state'=>'true']), 'far:edit blue');
  20. // vertical box container
  21. $container = new TVBox;
  22. $container->style = 'width: 100%';
  23. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  24. $container->add($this->form);
  25. parent::add($container);
  26. }
  27. /**
  28. * Show data
  29. */
  30. public function onEdit( $param )
  31. {
  32. try
  33. {
  34. TTransaction::open('grabovoi');
  35. $object = new Grabovoi($param['key']);
  36. $label_id = new TLabel('Id:', '#333333', '', 'B');
  37. $label_nome = new TLabel('Nome:', '#333333', '', 'B');
  38. $label_numero = new TLabel('Numero:', '#333333', '', 'B');
  39. $text_id = new TTextDisplay($object->id, '#333333', '', '');
  40. $text_nome = new TTextDisplay($object->nome, '#333333', '', '');
  41. $text_numero = new TTextDisplay($object->numero, '#333333', '', '');
  42. $this->form->addFields([$label_id],[$text_id]);
  43. $this->form->addFields([$label_nome],[$text_nome]);
  44. $this->form->addFields([$label_numero],[$text_numero]);
  45. TTransaction::close();
  46. }
  47. catch (Exception $e)
  48. {
  49. new TMessage('error', $e->getMessage());
  50. }
  51. }
  52. /**
  53. * Print view
  54. */
  55. public function onPrint($param)
  56. {
  57. try
  58. {
  59. $this->onEdit($param);
  60. // string with HTML contents
  61. $html = clone $this->form;
  62. $contents = file_get_contents('app/resources/styles-print.html') . $html->getContents();
  63. // converts the HTML template into PDF
  64. $dompdf = new \Dompdf\Dompdf();
  65. $dompdf->loadHtml($contents);
  66. $dompdf->setPaper('A4', 'portrait');
  67. $dompdf->render();
  68. $file = 'app/output/Grabovoi-export.pdf';
  69. // write and open file
  70. file_put_contents($file, $dompdf->output());
  71. $window = TWindow::create('Export', 0.8, 0.8);
  72. $object = new TElement('object');
  73. $object->data = $file.'?rndval='.uniqid();
  74. $object->type = 'application/pdf';
  75. $object->style = "width: 100%; height:calc(100% - 10px)";
  76. $window->add($object);
  77. $window->show();
  78. }
  79. catch (Exception $e)
  80. {
  81. new TMessage('error', $e->getMessage());
  82. }
  83. }
  84. }
  85. </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. * Form constructor
  11. * @param $param Request
  12. */
  13. public function __construct( $param )
  14. {
  15. parent::__construct();
  16. // creates the form
  17. $this->form = new BootstrapFormBuilder('form_Grabovoi');
  18. $this->form->setFormTitle('Grabovoi');
  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. /** samples
  36. $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  37. $fieldX->setSize( '100%' ); // set size
  38. **/
  39. // create the form actions
  40. $btn = $this->form->addAction(_t('Save'), new TAction([$this, 'onSave']), 'fa:save');
  41. $btn->class = 'btn btn-sm btn-primary';
  42. $this->form->addActionLink(_t('New'), new TAction([$this, 'onEdit']), 'fa:eraser red');
  43. // vertical box container
  44. $container = new TVBox;
  45. $container->style = 'width: 100%';
  46. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  47. $container->add($this->form);
  48. parent::add($container);
  49. }
  50. /**
  51. * Save form data
  52. * @param $param Request
  53. */
  54. public function onSave( $param )
  55. {
  56. try
  57. {
  58. TTransaction::open('grabovoi'); // open a transaction
  59. /**
  60. // Enable Debug logger for SQL operations inside the transaction
  61. TTransaction::setLogger(new TLoggerSTD); // standard output
  62. TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  63. **/
  64. $this->form->validate(); // validate form data
  65. $data = $this->form->getData(); // get form data as array
  66. $object = new Grabovoi; // create an empty object
  67. $object->fromArray( (array) $data); // load the object with data
  68. $object->store(); // save the object
  69. // get the generated id
  70. $data->id = $object->id;
  71. $this->form->setData($data); // fill form data
  72. TTransaction::close(); // close the transaction
  73. new TMessage('info', AdiantiCoreTranslator::translate('Record saved'));
  74. }
  75. catch (Exception $e) // in case of exception
  76. {
  77. new TMessage('error', $e->getMessage()); // shows the exception error message
  78. $this->form->setData( $this->form->getData() ); // keep form data
  79. TTransaction::rollback(); // undo all pending operations
  80. }
  81. }
  82. /**
  83. * Clear form data
  84. * @param $param Request
  85. */
  86. public function onClear( $param )
  87. {
  88. $this->form->clear(TRUE);
  89. }
  90. /**
  91. * Load object to form data
  92. * @param $param Request
  93. */
  94. public function onEdit( $param )
  95. {
  96. try
  97. {
  98. if (isset($param['key']))
  99. {
  100. $key = $param['key']; // get the parameter $key
  101. TTransaction::open('grabovoi'); // open a transaction
  102. $object = new Grabovoi($key); // instantiates the Active Record
  103. $this->form->setData($object); // fill the form
  104. TTransaction::close(); // close the transaction
  105. }
  106. else
  107. {
  108. $this->form->clear(TRUE);
  109. }
  110. }
  111. catch (Exception $e) // in case of exception
  112. {
  113. new TMessage('error', $e->getMessage()); // shows the exception error message
  114. TTransaction::rollback(); // undo all pending operations
  115. }
  116. }
  117. }
  118. </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. $this->form = new BootstrapFormBuilder('form_Grabovoi_View');
  16. $this->form->setFormTitle('Grabovoi');
  17. $this->form->setColumnClasses(2, ['col-sm-3', 'col-sm-9']);
  18. $this->form->addHeaderActionLink( _t('Print'), new TAction([$this, 'onPrint'], ['key'=>$param['key'], 'static' => '1']), 'far:file-pdf red');
  19. $this->form->addHeaderActionLink( _t('Edit'), new TAction(['GrabovoiForm1', 'onEdit'], ['key'=>$param['key'], 'register_state'=>'true']), 'far:edit blue');
  20. // vertical box container
  21. $container = new TVBox;
  22. $container->style = 'width: 100%';
  23. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  24. $container->add($this->form);
  25. parent::add($container);
  26. }
  27. /**
  28. * Show data
  29. */
  30. public function onEdit( $param )
  31. {
  32. try
  33. {
  34. TTransaction::open('grabovoi');
  35. $object = new Grabovoi($param['key']);
  36. $label_id = new TLabel('Id:', '#333333', '', 'B');
  37. $label_nome = new TLabel('Nome:', '#333333', '', 'B');
  38. $label_numero = new TLabel('Numero:', '#333333', '', 'B');
  39. $text_id = new TTextDisplay($object->id, '#333333', '', '');
  40. $text_nome = new TTextDisplay($object->nome, '#333333', '', '');
  41. $text_numero = new TTextDisplay($object->numero, '#333333', '', '');
  42. $this->form->addFields([$label_id],[$text_id]);
  43. $this->form->addFields([$label_nome],[$text_nome]);
  44. $this->form->addFields([$label_numero],[$text_numero]);
  45. TTransaction::close();
  46. }
  47. catch (Exception $e)
  48. {
  49. new TMessage('error', $e->getMessage());
  50. }
  51. }
  52. /**
  53. * Print view
  54. */
  55. public function onPrint($param)
  56. {
  57. try
  58. {
  59. $this->onEdit($param);
  60. // string with HTML contents
  61. $html = clone $this->form;
  62. $contents = file_get_contents('app/resources/styles-print.html') . $html->getContents();
  63. // converts the HTML template into PDF
  64. $dompdf = new \Dompdf\Dompdf();
  65. $dompdf->loadHtml($contents);
  66. $dompdf->setPaper('A4', 'portrait');
  67. $dompdf->render();
  68. $file = 'app/output/Grabovoi-export.pdf';
  69. // write and open file
  70. file_put_contents($file, $dompdf->output());
  71. $window = TWindow::create('Export', 0.8, 0.8);
  72. $object = new TElement('object');
  73. $object->data = $file.'?rndval='.uniqid();
  74. $object->type = 'application/pdf';
  75. $object->style = "width: 100%; height:calc(100% - 10px)";
  76. $window->add($object);
  77. $window->show();
  78. }
  79. catch (Exception $e)
  80. {
  81. new TMessage('error', $e->getMessage());
  82. }
  83. }
  84. }
  85. </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!!!