SystemGroupForm problemas no enableSearch Sou novato com o framework e me deparei com um problema que inclusive já existe na classe SystemGroupForm do Template. Existem 2 TCheckList nessa classe: 1º recebe program_list que adiciona as colunas id e name do modelo SystemProgram, o enableSearch é habilitado para coluna name. 2º recebe user_list que adiciona as colunas id e name do modelo SystemUser o enableSearch também é habilita...
EC
SystemGroupForm problemas no enableSearch  
Sou novato com o framework e me deparei com um problema que inclusive já existe na classe SystemGroupForm do Template.

Existem 2 TCheckList nessa classe:
1º recebe program_list que adiciona as colunas id e name do modelo SystemProgram, o enableSearch é habilitado para coluna name.
2º recebe user_list que adiciona as colunas id e name do modelo SystemUser o enableSearch também é habilitado para coluna name.

Provavelmente o fato do o enableSearch ser habilitado em colunas com o mesmo nome, apesar de serem modelos diferentes, estão conflitando e só a busca por programas funciona.

Já tentei usar o System::select e mudar com alias o retorno do select mas sem sucesso.

Se alguém poder ajudar com fazer funcionar.




 
  1. <?php
  2. parent::__construct();
  3. // creates the form
  4. $this->form = new BootstrapFormBuilder('form_System_group');
  5. $this->form->setFormTitle(_t('Group'));
  6. // create the form fields
  7. $id = new TEntry('id');
  8. $name = new TEntry('name');
  9. // define the sizes
  10. $id->setSize('30%');
  11. $name->setSize('70%');
  12. // validations
  13. $name->addValidation('name', new TRequiredValidator);
  14. // outras propriedades
  15. $id->setEditable(false);
  16. $this->form->addFields([new TLabel('ID')], [$id]);
  17. $this->form->addFields([new TLabel(_t('Name'))], [$name]);
  18. $this->program_list = new TCheckList('program_list');
  19. $this->program_list->setIdColumn('id');
  20. $this->program_list->addColumn('id', 'ID', 'center', '10%');
  21. $col_name = $this->program_list->addColumn('name', _t('Name'), 'left', '50%');
  22. $col_program = $this->program_list->addColumn('controller', _t('Menu path'), 'left', '40%');
  23. $col_program->enableAutoHide(500);
  24. $this->program_list->setHeight(350);
  25. $this->program_list->makeScrollable();
  26. $col_name->enableSearch();
  27. $search_program = $col_name->getInputSearch();
  28. $search_program->placeholder = _t('Search');
  29. $search_program->style = 'margin-left: 4px; border-radius: 4px';
  30. $col_program->setTransformer(function ($value, $object, $row) {
  31. $menuparser = new TMenuParser('menu.xml');
  32. $paths = $menuparser->getPath($value);
  33. if ($paths) {
  34. return implode(' &raquo; ', $paths);
  35. }
  36. });
  37. $this->user_list = new TCheckList('user_list');
  38. $this->user_list->setIdColumn('id');
  39. $this->user_list->addColumn('id', 'ID', 'center', '10%');
  40. $col_user = $this->user_list->addColumn('name', _t('Name'), 'left', '90%');
  41. $this->user_list->setHeight(350);
  42. $this->user_list->makeScrollable();
  43. $col_user->enableSearch();
  44. $search_user = $col_user->getInputSearch();
  45. $search_user->placeholder = _t('Search');
  46. $search_user->style = 'margin-left: 4px; border-radius: 4px';
  47. $subform = new BootstrapFormBuilder;
  48. $subform->setProperty('style', 'border:none; box-shadow:none');
  49. $subform->appendPage(_t('Programs'));
  50. $subform->addFields([$this->program_list]);
  51. $subform->appendPage(_t('Users'));
  52. $subform->addFields([$this->user_list]);
  53. $this->form->addContent([$subform]);
  54. TTransaction::open('permission');
  55. $this->program_list->addItems(SystemProgram::get());
  56. $this->user_list->addItems(SystemUser::get());
  57. TTransaction::close();
  58. $btn = $this->form->addAction(_t('Save'), new TAction(array($this, 'onSave')), 'far:save');
  59. $btn->class = 'btn btn-sm btn-primary';
  60. $this->form->addActionLink(_t('Clear'), new TAction(array($this, 'onEdit')), 'fa:eraser red');
  61. $this->form->addActionLink(_t('Back'), new TAction(array('SystemGroupList', 'onReload')), 'far:arrow-alt-circle-left blue');
  62. $container = new TVBox;
  63. $container->style = 'width:100%';
  64. $container->add(new TXMLBreadCrumb('menu.xml', 'SystemGroupList'));
  65. $container->add($this->form);
  66. // add the form to the page
  67. parent::add($container);
  68. ?>

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


NR

Tente o seguinte:
Altere "name" para "name2" na criação da coluna:
 
  1. <?php
  2. $col_name = $this->program_list->addColumn('name2', _t('Name'), 'left', '50%');
  3. ?>

No model SystemProgram crie uma função chamada "get_name2":
 
  1. <?php
  2. public function get_name2()
  3. {
  4. return $this->name;
  5. }
  6. ?>
EC

Nataniel Rabaioli, obrigado! É o mesmo método que o Pablo utiliza nas aulas quando quer pegar informações das tabelas de relacionamento. Show de bola! Já fica o exercício para utilizar esse "hack" para outras ocasiões.