Relacionamento entre tabelas, limpar campo e inserir imagens Amigos, Sou iniciante no Adianti Framework e estou com algumas dificuldades tais como: fazer o relacionamento entre tabelas, gravar imagem no banco de dados e limpar o campo de pesquisa após realizar consulta. Preciso que me ajudem nessa fase inicial. Segue os modelos: ...
ST
Relacionamento entre tabelas, limpar campo e inserir imagens  
Amigos,
Sou iniciante no Adianti Framework e estou com algumas dificuldades tais como: fazer o relacionamento entre tabelas, gravar imagem no banco de dados e limpar o campo de pesquisa após realizar consulta.
Preciso que me ajudem nessa fase inicial.

Segue os modelos:

 
  1. <?php
  2. /**
  3. * Perdcomp Active Record
  4. * @author <your-name-here>
  5. */
  6. class Perdcomp extends TRecord
  7. {
  8. const TABLENAME = 'perdcomp';
  9. const PRIMARYKEY= 'perdcomp_id';
  10. const IDPOLICY = 'max'; // {max, serial}
  11. private $origem_documento;
  12. private $tipo_credito;
  13. private $tipo_documento;
  14. private $tipo_imposto;
  15. /**
  16. * Constructor method
  17. */
  18. public function __construct($id = NULL, $callObjectLoad = TRUE)
  19. {
  20. parent::__construct($id, $callObjectLoad);
  21. parent::addAttribute('DataCriacao');
  22. parent::addAttribute('DataTransmissao');
  23. parent::addAttribute('Sequencial');
  24. parent::addAttribute('Nr_PERDCOMP');
  25. parent::addAttribute('TipoDocumento_id');
  26. parent::addAttribute('OrigemDocumento_id');
  27. parent::addAttribute('TipoCredito_id');
  28. parent::addAttribute('SaldoDeclarado');
  29. parent::addAttribute('Exercicio');
  30. parent::addAttribute('TipoImposto_ID');
  31. parent::addAttribute('ValorCompensado');
  32. parent::addAttribute('Competencia');
  33. parent::addAttribute('PERDCOMP_Original');
  34. parent::addAttribute('Situacao');
  35. parent::addAttribute('Coluna3');
  36. parent::addAttribute('Cancelamento');
  37. parent::addAttribute('CreditoOriginalInicial');
  38. parent::addAttribute('CreditoOriginalUtilizadoCompensacoes');
  39. parent::addAttribute('CreditoOriginalDisponivel');
  40. parent::addAttribute('CreditoOriginalTransmissao');
  41. parent::addAttribute('SelicAcumulada');
  42. parent::addAttribute('CreditoAtualizado');
  43. parent::addAttribute('DebitosDocumento');
  44. parent::addAttribute('CreditoOriginalUtilizadoDocumento');
  45. parent::addAttribute('SaldoCreditoOriginal');
  46. parent::addAttribute('GED');
  47. }
  48. /**
  49. * Method set_origem_documento
  50. * Sample of usage: $perdcomp->origem_documento = $object;
  51. * @param $object Instance of OrigemDocumento
  52. */
  53. public function set_origem_documento(OrigemDocumento $object)
  54. {
  55. $this->origem_documento = $object;
  56. $this->origem_documento_id = $object->id;
  57. }
  58. /**
  59. * Method get_origem_documento
  60. * Sample of usage: $perdcomp->origem_documento->attribute;
  61. * @returns OrigemDocumento instance
  62. */
  63. public function get_origem_documento()
  64. {
  65. // loads the associated object
  66. if (empty($this->origem_documento))
  67. $this->origem_documento = new OrigemDocumento($this->origem_documento_id);
  68. // returns the associated object
  69. return $this->origem_documento;
  70. }
  71. /**
  72. * Method set_tipo_credito
  73. * Sample of usage: $perdcomp->tipo_credito = $object;
  74. * @param $object Instance of TipoCredito
  75. */
  76. public function set_tipo_credito(TipoCredito $object)
  77. {
  78. $this->tipo_credito = $object;
  79. $this->tipo_credito_id = $object->id;
  80. }
  81. /**
  82. * Method get_tipo_credito
  83. * Sample of usage: $perdcomp->tipo_credito->attribute;
  84. * @returns TipoCredito instance
  85. */
  86. public function get_tipo_credito()
  87. {
  88. // loads the associated object
  89. if (empty($this->tipo_credito))
  90. $this->tipo_credito = new TipoCredito($this->tipo_credito_id);
  91. // returns the associated object
  92. return $this->tipo_credito->TipoCreditoDescricao;
  93. }
  94. /**
  95. * Method set_tipo_documento
  96. * Sample of usage: $perdcomp->tipo_documento = $object;
  97. * @param $object Instance of TipoDocumento
  98. */
  99. public function set_tipo_documento(TipoDocumento $object)
  100. {
  101. $this->tipo_documento = $object;
  102. $this->tipo_documento_id = $object->id;
  103. }
  104. /**
  105. * Method get_tipo_documento
  106. * Sample of usage: $perdcomp->tipo_documento->attribute;
  107. * @returns TipoDocumento instance
  108. */
  109. public function get_tipo_documento()
  110. {
  111. // loads the associated object
  112. if (empty($this->tipo_documento))
  113. $this->tipo_documento = new TipoDocumento($this->tipo_documento_id);
  114. // returns the associated object
  115. return $this->tipo_documento->TipoDocumentoDescricao;
  116. }
  117. /**
  118. * Method set_tipo_imposto
  119. * Sample of usage: $perdcomp->tipo_imposto = $object;
  120. * @param $object Instance of TipoImposto
  121. */
  122. public function set_tipo_imposto(TipoImposto $object)
  123. {
  124. $this->tipo_imposto = $object;
  125. $this->tipo_imposto_id = $object->id;
  126. }
  127. /**
  128. * Method get_tipo_imposto
  129. * Sample of usage: $perdcomp->tipo_imposto->attribute;
  130. * @returns TipoImposto instance
  131. */
  132. public function get_tipo_imposto()
  133. {
  134. // loads the associated object
  135. if (empty($this->tipo_imposto))
  136. $this->tipo_imposto = new TipoImposto($this->tipo_imposto_id);
  137. // returns the associated object
  138. return $this->tipo_imposto;
  139. }
  140. }
 
  1. <?php
  2. /**
  3. * Tipodocumento Active Record
  4. * @author <your-name-here>
  5. */
  6. class TipoDocumento extends TRecord
  7. {
  8. const TABLENAME = 'tipodocumento';
  9. const PRIMARYKEY= 'TipoDocumento_id';
  10. const IDPOLICY = 'max'; // {max, serial}
  11. /**
  12. * Constructor method
  13. */
  14. public function __construct($id = NULL, $callObjectLoad = TRUE)
  15. {
  16. parent::__construct($id, $callObjectLoad);
  17. parent::addAttribute('TipoDocumentoDescricao');
  18. }
  19. }
 
  1. <?php
  2. /**
  3. * Tipocredito Active Record
  4. * @author <your-name-here>
  5. */
  6. class TipoCredito extends TRecord
  7. {
  8. const TABLENAME = 'tipocredito';
  9. const PRIMARYKEY= 'TipoCredito_id';
  10. const IDPOLICY = 'max'; // {max, serial}
  11. /**
  12. * Constructor method
  13. */
  14. public function __construct($id = NULL, $callObjectLoad = TRUE)
  15. {
  16. parent::__construct($id, $callObjectLoad);
  17. parent::addAttribute('TipoCreditoDescricao');
  18. }
  19. }
  20. Segue os formulários:
 
  1. <?php
  2. /**
  3. * PerdcompForm Registration
  4. * @author <your name here>
  5. */
  6. class PerdcompForm extends TPage
  7. {
  8. protected $form; // form
  9. use Adianti\Base\AdiantiStandardFormTrait; // Standard form methods
  10. /**
  11. * Class constructor
  12. * Creates the page and the registration form
  13. */
  14. function __construct()
  15. {
  16. parent::__construct();
  17. $this->setDatabase('perdcomp'); // defines the database
  18. $this->setActiveRecord('Perdcomp'); // defines the active record
  19. // creates the form
  20. $this->form = new TQuickForm('form_Perdcomp');
  21. $this->form->class = 'tform'; // change CSS class
  22. $this->form->style = 'display: table;width:100%'; // change style
  23. // define the form title
  24. $this->form->setFormTitle('Perdcomp');
  25. // create the form fields
  26. $perdcomp_id = new TEntry('perdcomp_id');
  27. $DataCriacao = new TDate('DataCriacao');
  28. $DataTransmissao = new TDate('DataTransmissao');
  29. $Sequencial = new TEntry('Sequencial');
  30. $Nr_PERDCOMP = new TEntry('Nr_PERDCOMP');
  31. $TipoDocumento_id = new ">TDBSeekButton('TipoDocumento_id', 'perdcomp', $this->form->getName(), 'TipoDocumento', 'TipoDocumentoDescricao', 'TipoDocumento_id', 'TipoDocumentoDescricao');
  32. $TipodocumentoDescricao = new TEntry('TipoDocumentoDescricao');
  33. $OrigemdoDocumento_id = new ">TDBSeekButton('OrigemDocumento_id', 'perdcomp', $this->form->getName(), 'OrigemDocumento', 'OrigemDocumentoDescricao', 'OrigemDocumento_id', 'OrigemDocumentoDescricao');
  34. $OrigemDocumentoDescricao = new TEntry('OrigemDocumentoDescricao');
  35. $TipoCredito_id = new ">TDBSeekButton('TipoCredito_id', 'perdcomp', $this->form->getName(), 'TipoCredito', 'TipoCreditoDescricao', 'TipoCredito_id', 'TipoCreditoDescricao');
  36. $TipoCreditoDescricao = new TEntry('TipoCreditoDescricao');
  37. $SaldoDeclarado = new TEntry('SaldoDeclarado');
  38. $Exercicio = new TEntry('Exercicio');
  39. // $TipoImposto_ID = new TSeekButton('TipoImposto_ID');
  40. $TipoImposto_id = new ">TDBSeekButton('TipoImposto_id', 'perdcomp', $this->form->getName(), 'TipoImposto', 'TipoImposto_Descricao', 'TipoImposto_id', 'TipoImposto_Descricao');
  41. $TipoImpostoDescricao = new TEntry('TipoImpostoDescricao');
  42. $ValorCompensado = new TEntry('ValorCompensado');
  43. $Competencia = new TEntry('Competencia');
  44. $PERDCOMP_Original = new TEntry('PERDCOMP_Original');
  45. $Situacao = new TEntry('Situacao');
  46. $Coluna3 = new TEntry('Coluna3');
  47. $Cancelamento = new TEntry('Cancelamento');
  48. $CreditoOriginalInicial = new TEntry('CreditoOriginalInicial');
  49. $CreditoOriginalUtilizadoCompensacoes = new TEntry('CreditoOriginalUtilizadoCompensacoes');
  50. $CreditoOriginalDisponivel = new TEntry('CreditoOriginalDisponivel');
  51. $CreditoOriginalTransmissao = new TEntry('CreditoOriginalTransmissao');
  52. $SelicAcumulada = new TEntry('SelicAcumulada');
  53. $CreditoAtualizado = new TEntry('CreditoAtualizado');
  54. $DebitosDocumento = new TEntry('DebitosDocumento');
  55. $CreditoOriginalUtilizadoDocumento = new TEntry('CreditoOriginalUtilizadoDocumento');
  56. $SaldoCreditoOriginal = new TEntry('SaldoCreditoOriginal');
  57. $GED = new TFile('GED');
  58. $TipoDocumentoDescricao->setEditable(FALSE);
  59. $TipoDocumento_id->setSize('40');
  60. $TipoDocumentoDescricao->setSize('500');
  61. $OrigemDocumentoDescricao->setEditable(FALSE);
  62. $OrigemdDcumento_id->setSize('40');
  63. $OrigemDocumentoDescricao->setSize('500');
  64. $TipoCreditoDescricao->setEditable(FALSE);
  65. $TipoCredito_id->setSize('40');
  66. $TipoCreditoDescricao->setSize('500');
  67. $TipoImpostoDescricao->setEditable(FALSE);
  68. $TipoImposto_id->setSize('40');
  69. $TipoImpostoDescricao->setSize('500');
  70. // add the fields
  71. $this->form->addQuickField('Código:', $perdcomp_id, 100 );
  72. $this->form->addQuickField('Data Criação:', $DataCriacao, 100 );
  73. $this->form->addQuickField('Data Transmissão:', $DataTransmissao, 100 );
  74. $this->form->addQuickField('Sequencial:', $Sequencial, 200 );
  75. $this->form->addQuickField('Nº Perdcomp:', $Nr_PERDCOMP, 200 );
  76. $this->form->addQuickFields('Tipo Documento:', [ $TipoDocumento_id, $TipodocumentoDescricao ] );
  77. $this->form->addQuickFields('Origem Documento:', [ $OrigemDocumento_id, $OrigemDocumentoDescricao ] );
  78. $this->form->addQuickFields('Tipo Crédito:', [ $TipoCredito_id, $TipoCreditoDescricao] );
  79. $this->form->addQuickField('Saldo Declarado:', $SaldoDeclarado, 150 );
  80. $this->form->addQuickField('Exercicio:', $Exercicio, 100 );
  81. $this->form->addQuickFields('Tipo Imposto:', [ $TipoImposto_id, $TipoImpostoDescricao] );
  82. $this->form->addQuickField('Valor Compensado:', $ValorCompensado, 150 );
  83. $this->form->addQuickField('Competência:', $Competencia, 100 );
  84. $this->form->addQuickField('Perdcomp Original:', $PERDCOMP_Original, 200 );
  85. $this->form->addQuickField('Situação:', $Situacao, 200 );
  86. $this->form->addQuickField('Coluna3:', $Coluna3, 200 );
  87. $this->form->addQuickField('Cancelamento:', $Cancelamento, 200 );
  88. $this->form->addQuickField('Crédito Original Inicial:', $CreditoOriginalInicial, 150 );
  89. $this->form->addQuickField('Crédito Original Utilizado Compensações:', $CreditoOriginalUtilizadoCompensacoes, 150 );
  90. $this->form->addQuickField('Crédito Original Disponível:', $CreditoOriginalDisponivel, 150 );
  91. $this->form->addQuickField('Crédito Original Transmissão:', $CreditoOriginalTransmissao, 150 );
  92. $this->form->addQuickField('Selic Acumulada:', $SelicAcumulada, 150 );
  93. $this->form->addQuickField('Crédito Atualizado:', $CreditoAtualizado, 150 );
  94. $this->form->addQuickField('Débitos Documento:', $DebitosDocumento, 150 );
  95. $this->form->addQuickField('Crédito Original Utilizado Documento:', $CreditoOriginalUtilizadoDocumento, 150, new TRequiredValidator );
  96. $this->form->addQuickField('Saldo Crédito Original:', $SaldoCreditoOriginal, 150 , new TRequiredValidator);
  97. $this->form->addQuickField('Ged:', $GED, 500 );
  98. if (!empty($perdcomp_id))
  99. {
  100. $perdcomp_id->setEditable(FALSE);
  101. }
  102. /** samples
  103. $this->form->addQuickFields('Date', array($date1, new TLabel('to'), $date2)); // side by side fields
  104. $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  105. $fieldX->setSize( 100, 40 ); // set size
  106. **/
  107. // create the form actions
  108. $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'fa:floppy-o');
  109. $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'bs:plus-sign green');
  110. $this->form->addQuickAction(_t('Back to the listing'), new TAction(array('PerdcompList', 'onReload')), 'fa:table blue');
  111. // vertical box container
  112. $container = new TVBox;
  113. $container->style = 'width: 90%';
  114. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  115. $container->add($this->form);
  116. parent::add($container);
  117. }
  118. }
 
  1. <?php
  2. /**
  3. * PerdcompList Listing
  4. * @author <your name here>
  5. */
  6. class PerdcompList extends TStandardList
  7. {
  8. protected $form; // registration form
  9. protected $datagrid; // listing
  10. protected $pageNavigation;
  11. protected $formgrid;
  12. protected $deleteButton;
  13. protected $transformCallback;
  14. /**
  15. * Page constructor
  16. */
  17. public function __construct()
  18. {
  19. parent::__construct();
  20. parent::setDatabase('perdcomp'); // defines the database
  21. parent::setActiveRecord('Perdcomp'); // defines the active record
  22. parent::setDefaultOrder('perdcomp_id', 'asc'); // defines the default order
  23. // parent::setCriteria($criteria) // define a standard filter
  24. parent::addFilterField('DataCriacao', 'like', 'DataCriacao'); // filterField, operator, formField
  25. parent::addFilterField('DataTransmissao', 'like', 'DataTransmissao'); // filterField, operator, formField
  26. parent::addFilterField('Nr_PERDCOMP', 'like', 'Nr_PERDCOMP'); // filterField, operator, formField
  27. parent::addFilterField('TipoDocumento_id', 'like', 'TipoDocumento_id'); // filterField, operator, formField
  28. parent::addFilterField('TipoCredito_id', 'like', 'TipoCredito_id'); // filterField, operator, formField
  29. // creates the form
  30. $this->form = new TQuickForm('form_search_Perdcomp');
  31. $this->form->class = 'tform'; // change CSS class
  32. $this->form->style = 'display: table;width:100%'; // change style
  33. $this->form->setFormTitle('Perdcomp');
  34. // create the form fields
  35. $DataCriacao = new TDate('DataCriacao');
  36. $DataTransmissao = new TDate('DataTransmissao');
  37. $Nr_PERDCOMP = new TEntry('Nr_PERDCOMP');
  38. // $TipoDocumento_id = new TSeekButton('TipoDocumento_id');
  39. $TipoDocumento_id = new ">TDBSeekButton('TipoDocumento_id', 'perdcomp', $this->form->getName(), 'TipoDocumento', 'TipoDocumentoDescricao', 'TipoDocumento_id', 'TipoDocumentoDescricao');
  40. $TipoDocumentoDescricao = new TEntry('TipoDocumentoDescricao');
  41. // $TipoCredito_id = new TSeekButton('TipoCredito_id');
  42. $TipoCredito_id = new ">TDBSeekButton('TipoCredito_id', 'perdcomp', $this->form->getName(), 'TipoCredito', 'TipoCreditoDescricao', 'TipoCredito_id', 'TipoCreditoDescricao');
  43. $TipoCreditoDescricao = new TEntry('TipoCreditoDescricao');
  44. $TipoDocumentoDescricao->setEditable(FALSE);
  45. $TipoDocumento_id->setSize('40');
  46. $TipoDocumentoDescricao->setSize('500');
  47. $TipoCreditoDescricao->setEditable(FALSE);
  48. $TipoCredito_id->setSize('40');
  49. $TipoCreditoDescricao->setSize('500');
  50. // add the fields
  51. $this->form->addQuickField('Data Criação', $DataCriacao, 80 );
  52. $this->form->addQuickField('Data Transmissão', $DataTransmissao, 80 );
  53. $this->form->addQuickField('Nº Perdcomp', $Nr_PERDCOMP, 200 );
  54. $this->form->addQuickFields('Tipo Documento:', [ $TipoDocumento_id, $TipoDocumentoDescricao ] );
  55. $this->form->addQuickFields('Tipo Crédito:', [ $TipoCredito_id, $TipoCreditoDescricao] );
  56. // keep the form filled during navigation with session data
  57. $this->form->setData( TSession::getValue('Perdcomp_filter_data') );
  58. // add the search form actions
  59. $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'fa:search');
  60. $this->form->addQuickAction(_t('New'), new TAction(array('PerdcompForm', 'onEdit')), 'bs:plus-sign green');
  61. // creates a DataGrid
  62. $this->datagrid = new TDataGrid;
  63. $this->datagrid->style = 'width: 100%';
  64. $this->datagrid->datatable = 'true';
  65. // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  66. // creates the datagrid columns
  67. $column_DataCriacao = new TDataGridColumn('DataCriacao', 'Data Criação', 'left');
  68. $column_DataTransmissao = new TDataGridColumn('DataTransmissao', 'Data Transmissão', 'left');
  69. $column_Nr_PERDCOMP = new TDataGridColumn('Nr_PERDCOMP', 'Nº Perdcomp', 'left');
  70. $column_TipoDocumentoDescricao = new TDataGridColumn('tipo_documento->TipoDocumentoDescricao', 'Tipo Documento', 'left');
  71. $column_TipoCreditoDescricao = new TDataGridColumn('tipo_credito->TipoCreditoDescricao', 'Tipo Crédito','left');
  72. $column_GED = new TDataGridColumn('GED', 'Ged', 'left');
  73. // add the columns to the DataGrid
  74. $this->datagrid->addColumn($column_DataCriacao);
  75. $this->datagrid->addColumn($column_DataTransmissao);
  76. $this->datagrid->addColumn($column_Nr_PERDCOMP);
  77. $this->datagrid->addColumn($column_TipoDocumentoDescricao);
  78. $this->datagrid->addColumn($column_TipoCreditoDescricao);
  79. $this->datagrid->addColumn($column_GED);
  80. // creates the datagrid column actions
  81. $order_DataCriacao = new TAction(array($this, 'onReload'));
  82. $order_DataCriacao->setParameter('order', 'DataCriacao');
  83. $column_DataCriacao->setAction($order_DataCriacao);
  84. $order_DataTransmissao = new TAction(array($this, 'onReload'));
  85. $order_DataTransmissao->setParameter('order', 'DataTransmissao');
  86. $column_DataTransmissao->setAction($order_DataTransmissao);
  87. $order_Nr_PERDCOMP = new TAction(array($this, 'onReload'));
  88. $order_Nr_PERDCOMP->setParameter('order', 'Nr_PERDCOMP');
  89. $column_Nr_PERDCOMP->setAction($order_Nr_PERDCOMP);
  90. // inline editing
  91. $DataCriacao_edit = new TDataGridAction(array($this, 'onInlineEdit'));
  92. $DataCriacao_edit->setField('perdcomp_id');
  93. $column_DataCriacao->setEditAction($DataCriacao_edit);
  94. $DataTransmissao_edit = new TDataGridAction(array($this, 'onInlineEdit'));
  95. $DataTransmissao_edit->setField('perdcomp_id');
  96. $column_DataTransmissao->setEditAction($DataTransmissao_edit);
  97. $Nr_PERDCOMP_edit = new TDataGridAction(array($this, 'onInlineEdit'));
  98. $Nr_PERDCOMP_edit->setField('perdcomp_id');
  99. $column_Nr_PERDCOMP->setEditAction($Nr_PERDCOMP_edit);
  100. $GED_edit = new TDataGridAction(array($this, 'onInlineEdit'));
  101. $GED_edit->setField('perdcomp_id');
  102. $column_GED->setEditAction($GED_edit);
  103. // define the transformer method over image
  104. $column_DataCriacao->setTransformer( function($value, $object, $row) {
  105. $date = new DateTime($value);
  106. return $date->format('d/m/Y');
  107. });
  108. // define the transformer method over image
  109. $column_DataTransmissao->setTransformer( function($value, $object, $row) {
  110. $date = new DateTime($value);
  111. return $date->format('d/m/Y');
  112. });
  113. // define the transformer method over image
  114. $column_GED->setTransformer( function($value, $object, $row) {
  115. if (file_exists($value)) {
  116. return new TImage($value);
  117. }
  118. });
  119. // create EDIT action
  120. $action_edit = new TDataGridAction(array('PerdcompForm', 'onEdit'));
  121. // $action_edit->setUseButton(TRUE);
  122. $action_edit->setButtonClass('btn btn-default');
  123. $action_edit->setLabel(_t('Edit'));
  124. $action_edit->setImage('fa:pencil-square-o blue fa-lg');
  125. $action_edit->setField('perdcomp_id');
  126. $this->datagrid->addAction($action_edit);
  127. // create DELETE action
  128. $action_del = new TDataGridAction(array($this, 'onDelete'));
  129. // $action_del->setUseButton(TRUE);
  130. $action_del->setButtonClass('btn btn-default');
  131. $action_del->setLabel(_t('Delete'));
  132. $action_del->setImage('fa:trash-o red fa-lg');
  133. $action_del->setField('perdcomp_id');
  134. $this->datagrid->addAction($action_del);
  135. // create the datagrid model
  136. $this->datagrid->createModel();
  137. // create the page navigation
  138. $this->pageNavigation = new TPageNavigation;
  139. $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
  140. $this->pageNavigation->setWidth($this->datagrid->getWidth());
  141. // vertical box container
  142. $container = new TVBox;
  143. $container->style = 'width: 90%';
  144. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  145. $container->add($this->form);
  146. $container->add($this->datagrid);
  147. $container->add($this->pageNavigation);
  148. parent::add($container);
  149. }
  150. }

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


MG

Veja abaixo um trecho do código com relacionamento

Neste trecho o atributo na tabela deve ser o mesmo nome do atributo do relacionamento: $this->cliente = new Cliente($this->cliente_id);
$this->cliente_id = refere-se ao atributo "cliente_id" da tabela relacionada

Neste trecho, fazemos referência ao $object->id qe é "clientes", com $this->cliente_id da tabela relacionada :$this->cliente_id = $object->id;

O atributo da tabela relacionada está com o mesmo nome?

<php
/**
* Method set_cliente
* Sample of usage: $backlog->cliente = $object;
* @param $object Instance of Cliente
*/
public function set_cliente(Cliente $object)
{
$this->cliente = $object;
$this->cliente_id = $object->id;
}

/**
* Method get_cliente
* Sample of usage: $backlog->cliente->attribute;
* @returns Cliente instance
*/
public function get_cliente()
{
// loads the associated object
if (empty($this->cliente))
$this->cliente = new Cliente($this->cliente_id);

// returns the associated object
return $this->cliente;
}
>
MG

Respondendo as demais perguntas:
Limpar campos = normalmente ao inserir um registro, ou mantemos o registro na tela com o ID gerado para edição, ou redirecionamos para um lista. Se deseja voltar a tela como novo registro, ao salvar vc pode simplesmente não utilizar: $this->form->setData($dados);
Imgens: vc diz fazer upload?
ST

Problema resolvido.
Muito obrigado Marcelo.