TEntry->forceUpperCase() Pessoal, Estou usando Adianti Framework 7 e ao tentar utilizar os métodos forceUpperCase () e forceLowerCase() estou tendo o seguinte erro: Fatal error: Uncaught Error: Call to undefined function forceUpperCase() in C:xampphtdocsocorrenciasappcontrolBzmAgenteForm.php:45 Stack trace: #0 C:xampphtdocsocorrenciaslibadianticoreAdiantiCoreApplication.php(80): BzmAgenteForm->__c...
CD
TEntry->forceUpperCase()  
Pessoal,

Estou usando Adianti Framework 7 e ao tentar utilizar os métodos forceUpperCase () e forceLowerCase() estou tendo o seguinte erro:


Fatal error: Uncaught Error: Call to undefined function forceUpperCase() in C:xampphtdocsocorrenciasappcontrolBzmAgenteForm.php:45
Stack trace:
#0 C:xampphtdocsocorrenciaslibadianticoreAdiantiCoreApplication.php(80): BzmAgenteForm->__construct(Array)
#1 C:xampphtdocsocorrenciasengine.php(27): AdiantiCoreAdiantiCoreApplication::run('1')
#2 C:xampphtdocsocorrenciasengine.php(68): TApplication::run()
#3 {main}
thrown in C:xampphtdocsocorrenciasappcontrolBzmAgenteForm.php on line 45


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

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


MG

Carlos

Veja a linha abaixo, está errado. Acredito que seja isso!

 
  1. <?php
  2. $CONTATO>forceUpperCase(); // correto $CONTATO->forceUpperCase() - faltou o hífen
  3. ?>