Adianti Tutor: Notice: A non well formed numeric value encounter Boa noite! Baixei o tutor e na MANUALDATAGRID está retornando a seguinte mensagem de erro: Notice: A non well formed numeric value encountered in D:xampphtdocstutorlibadiantiwidgetdatagridTDataGrid.php on line 842. Alguém com o mesmo problema?...
MB
Adianti Tutor: Notice: A non well formed numeric value encounter  
Boa noite!

Baixei o tutor e na MANUALDATAGRID está retornando a seguinte mensagem de erro: Notice: A non well formed numeric value encountered in D:xampphtdocstutorlibadiantiwidgetdatagridTDataGrid.php on line 842.

Alguém com o mesmo problema?

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


MB

O problema era referencia a versao do PHP. Instalei o XAMPP com o PHP 7.0.18 e apareceu essa outra mensagem:

The class nome was not found. Check the class name or the file name. They must match

Abaixo codigo da class ContatoList

 
  1. <?php
  2. class ContatoList extends TPage
  3. {
  4. private $form; //registrando form
  5. private $datagrid; //listagem
  6. private $pageNavigation; //navegação pelas páginas
  7. private $loaded;
  8. public function __construct()
  9. {
  10. parent::__construct();
  11. //criando form
  12. $this->form = new TQuickForm('ContatoList');
  13. $this->form->setFormTitle('Listagem de Contatos');
  14. $this->form->class = 'tform';
  15. $nome = new TEntry('nome');
  16. $this->form->addQuickField( 'Nome:', $nome, '70%' );
  17. $this->form->addQuickAction('Buscar', new TAction(array($this, 'onSearch')), 'fa:search blue');
  18. $this->form->addQuickAction('Novo', new TAction(array('ContatoForm', 'onClear')), 'fa:plus-circle green');
  19. $nome->setValue( TSession::getValue( 'nome' ) );
  20. $this->datagrid = new TDataGrid;
  21. $this->datagrid->style = 'width: 100%';
  22. $id_contato = new TDataGridColumn('id_contato', 'Id', 'right', '10%');
  23. $celular = new TDataGridColumn('celular', 'Celular', 'left', '20%');
  24. $nome = new TDataGridColumn('nome', 'Nome', 'center', '20%');
  25. $datanascimento = new TDataGridColumn('datanascimento', 'Nascimento', 'center', '30%');
  26. $comprou = new TDataGridColumn('comprou', 'Comprou', 'center', '30%');
  27. $naocomprou = new TDataGridColumn('naocomprou', 'Motivo', 'center', '30%');
  28. $interesse = new TDataGridColumn('interesse', 'Interesse', 'center', '30%');
  29. $opcoes = new TDataGridColumn('opcoes', 'Opções', 'center', '30%');
  30. $genero = new TDataGridColumn('genero', 'Genero', 'center', '30%');
  31. $order1 = new TAction(array($this, 'onReload'));
  32. $order2 = new TAction(array($this, 'onReload'));
  33. $order1->setParameter('order', 'id_contato');
  34. $order2->setParameter('order', 'nome');
  35. $id_contato->setAction($order1);
  36. $nome->setAction($order2);
  37. $this->datagrid->addColumn($id_contato);
  38. $this->datagrid->addColumn($celular);
  39. $this->datagrid->addColumn($nome);
  40. $this->datagrid->addColumn($datanascimento);
  41. $this->datagrid->addColumn($comprou);
  42. $this->datagrid->addColumn($naocomprou);
  43. $this->datagrid->addColumn($interesse);
  44. $this->datagrid->addColumn($opcoes);
  45. $this->datagrid->addColumn($genero);
  46. $action1 = new TDataGridAction(array('ContatoForm', 'onEdit'));
  47. $action1->setLabel('Editar');
  48. $action1->setImage('fa:edit blue');
  49. $action1->setField('id_contato');
  50. $action2 = new TDataGridAction(array($this, 'onDelete'));
  51. $action2->setLabel('Delete');
  52. $action2->setImage('fa:trash red');
  53. $action2->setField('id_contato');
  54. $this->datagrid->addAction($action1);
  55. $this->datagrid->addAction($action2);
  56. $this->datagrid->createModel();
  57. $this->pageNavigation = new TPageNavigation;
  58. $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
  59. $this->pageNavigation->setWidth($this->datagrid->getWidth());
  60. $vbox = new TVBox;
  61. $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  62. $vbox->add($this->form); // add a row to the form
  63. $vbox->add($this->datagrid); // add a row to the datagrid
  64. $vbox->add($this->pageNavigation);
  65. parent::add($vbox);
  66. }
  67. function onSearch()
  68. {
  69. // get the search form data
  70. $data = $this->form->getData();
  71. // check if the user has filled the form
  72. if (isset($data->nome))
  73. {
  74. // creates a filter using what the user has typed
  75. $filter = new TFilter('nome', 'like', "%{$data->nome}%");
  76. // stores the filter in the session
  77. TSession::setValue('id_contato', $filter);
  78. TSession::setValue('nome', $data->nome);
  79. // fill the form with data again
  80. $this->form->setData($data);
  81. }
  82. $param = array();
  83. $param['offset'] =0;
  84. $param['first_page']=1;
  85. $this->onReload($param);
  86. }
  87. function onReload($param = NULL)
  88. {
  89. try
  90. {
  91. // open a transaction with database 'samples'
  92. TTransaction::open('dbmodaviva');
  93. // creates a repository for City
  94. $repository = new TRepository('nome');
  95. $limit = 10;
  96. // creates a criteria
  97. $criteria = new TCriteria;
  98. // default order
  99. if (empty($param['order']))
  100. {
  101. $param['order'] = 'id_contato';
  102. $param['direction'] = 'asc';
  103. }
  104. $criteria->setProperties($param); // order, offset
  105. $criteria->setProperty('limit', $limit);
  106. if (TSession::getValue('nome'))
  107. {
  108. // add the filter stored in the session to the criteria
  109. $criteria->add(TSession::getValue('nome'));
  110. }
  111. // load the objects according to criteria
  112. $objects = $repository->load($criteria);
  113. $this->datagrid->clear();
  114. if ($objects)
  115. {
  116. // iterate the collection of active records
  117. foreach ($objects as $object)
  118. {
  119. // add the object inside the datagrid
  120. $this->datagrid->addItem($object);
  121. }
  122. }
  123. // reset the criteria for record count
  124. $criteria->resetProperties();
  125. $count= $repository->count($criteria);
  126. $this->pageNavigation->setCount($count); // count of records
  127. $this->pageNavigation->setProperties($param); // order, page
  128. $this->pageNavigation->setLimit($limit); // limit
  129. // close the transaction
  130. TTransaction::close();
  131. $this->loaded = true;
  132. }
  133. catch (Exception $e) // in case of exception
  134. {
  135. // shows the exception error message
  136. new TMessage('error', $e->getMessage());
  137. // undo all pending operations
  138. TTransaction::rollback();
  139. }
  140. }
  141. /**
  142. * method onDelete()
  143. * executed whenever the user clicks at the delete button
  144. * Ask if the user really wants to delete the record
  145. */
  146. function onDelete($param)
  147. {
  148. // define the delete action
  149. $action = new TAction(array($this, 'Delete'));
  150. $action->setParameters($param); // pass the key parameter ahead
  151. // shows a dialog to the user
  152. new TQuestion('Do you really want to delete ?', $action);
  153. }
  154. function Delete($param)
  155. {
  156. try
  157. {
  158. // get the parameter $key
  159. $key = $param['id_contato'];
  160. TTransaction::open('dbmodaviva'); // open a transaction with database 'samples'
  161. $object = new City($key); // instantiates object City
  162. $object->delete(); // deletes the object from the database
  163. TTransaction::close(); // close the transaction
  164. // reload the listing
  165. $this->onReload( $param );
  166. // shows the success message
  167. new TMessage('info', "Record Deleted");
  168. }
  169. catch (Exception $e) // in case of exception
  170. {
  171. // shows the exception error message
  172. new TMessage('error', $e->getMessage());
  173. // undo all pending operations
  174. TTransaction::rollback();
  175. }
  176. }
  177. /**
  178. * method show()
  179. * Shows the page
  180. */
  181. function show()
  182. {
  183. // check if the datagrid is already loaded
  184. if (!$this->loaded)
  185. {
  186. $this->onReload( func_get_arg(0) );
  187. }
  188. parent::show();
  189. }
  190. }
  191. ?>


NR

Ao criar um TRepository você deve informar o nome da classe modelo que será utilizada como base. Você está informando "nome". Não deveria ser "Contato"?
 
  1. <?php
  2. //$repository = new TRepository('nome');
  3. $repository = new TRepository('Contato');
  4. ?>

MB

Obg! Tudo funcionando...vlw