Aumentar tamanho de campo TFieldList Pessoal, Tenho o formulário abaixo, como no exemplo CustomerFormView do Tutor. Gostaria de aumentar o tamanho do campo TDBUniqueSearch do formulário. Alguém saber? Obrigado ...
CJ
Aumentar tamanho de campo TFieldList  
Pessoal,

Tenho o formulário abaixo, como no exemplo CustomerFormView do Tutor. Gostaria de aumentar o tamanho do campo TDBUniqueSearch do formulário.

Alguém saber? Obrigado

 
  1. <?php
 
  1. <?php
  2. /**
  3. * FuncionarioForm Form
  4. * @author <your name here>
  5. */
  6. class FuncionarioForm extends TPage
  7. {
  8. protected $form; // form
  9. private $cursos;
  10. /**
  11. * Form constructor
  12. * @param $param Request
  13. */
  14. public function __construct( $param )
  15. {
  16. parent::__construct();
  17. // creates the form
  18. $this->form = new BootstrapFormBuilder('form_Funcionario');
  19. $this->form->setFormTitle('Funcionário');
  20. // create the form fields
  21. $id = new THidden('id');
  22. $nome = new TEntry('nome');
  23. $endereco = new TEntry('endereco');
  24. $numero = new TEntry('numero');
  25. $complem = new TEntry('complem');
  26. $bairro = new TEntry('bairro');
  27. $cidade = new TEntry('cidade');
  28. $uf = new TEntry('uf');
  29. $cep = new TEntry('cep');
  30. $nacionalidade = new TEntry('nacionalidade');
  31. $naturalidade = new TEntry('naturalidade');
  32. $uf_natural = new TEntry('uf_natural');
  33. $data_nascimento = new TDate('data_nascimento');
  34. $telefone = new TEntry('telefone');
  35. $celular = new TEntry('celular');
  36. $email = new TEntry('email');
  37. $sexo = new TEntry('sexo');
  38. $estadocivil = new TEntry('estadocivil');
  39. $racacor = new TEntry('racacor');
  40. $pai = new TEntry('pai');
  41. $mae = new TEntry('mae');
  42. $grauinstrucao_id = new TCombo('grauinstrucao_id');
  43. $rg = new TEntry('rg');
  44. $rg_data = new TDate('rg_data');
  45. $rg_orgao = new TEntry('rg_orgao');
  46. $cpf = new TEntry('cpf');
  47. $ct = new TEntry('ct');
  48. $ct_serie = new TEntry('ct_serie');
  49. $ct_uf = new TEntry('ct_uf');
  50. $ct_data = new TDate('ct_data');
  51. $reg_profissional = new TEntry('reg_profissional');
  52. $cnh = new TEntry('cnh');
  53. $titulo = new TEntry('titulo');
  54. $titulo_zona = new TEntry('titulo_zona');
  55. $titulo_secao = new TEntry('titulo_secao');
  56. $titulo_cidade = new TEntry('titulo_cidade');
  57. $pis_pasep = new TEntry('pis_pasep');
  58. $pis_pasep_data = new TDate('pis_pasep_data');
  59. $obs = new TText('obs');
  60. $pendencias = new TText('pendencias');
  61. $ativo = new TEntry('ativo');
  62. $banco_id = new TEntry('banco_id');
  63. $agencia = new TEntry('agencia');
  64. $conta = new TEntry('conta');
  65. $operacao = new TEntry('operacao');
  66. // Aba Dados Gerais
  67. $this->form->appendPage('Dados Gerais');
  68. $this->form->addContent([ new TFormSeparator('Funcionário', '#18953c', '18', '#eeeeee')] );
  69. $this->form->addFields( [ $id]);
  70. $this->form->addFields( [ new TLabel('Ativo')], [$ativo], [new TLabel('CPF', 'red')], [$cpf] );
  71. $this->form->addFields( [ new TLabel('Nome', 'red')], [$nome] );
  72. $this->form->addFields( [ new TLabel('Data Nasc') ], [ $data_nascimento ], [new TLabel('Sexo') ], [ $sexo ] );
  73. $this->form->addFields( [ new TLabel('Raça/Cor') ], [ $racacor ], [new TLabel('Estado Civil') ], [ $estadocivil ] );
  74. $this->form->addFields( [ new TLabel('Naturalidade') ], [ $naturalidade], [ new TLabel('UF') ], [ $uf_natural ] );
  75. $this->form->addContent([ new TFormSeparator('Filiação', '#18953c', '18', '#eeeeee')] );
  76. $this->form->addFields( [ new TLabel('Nome Pai') ], [ $pai ], [ new TLabel('Nome Mãe') ], [ $mae ] );
  77. $this->form->addContent([ new TFormSeparator('Endereço', '#18953c', '18', '#eeeeee')] );
  78. $this->form->addFields( [ new TLabel('Endereço') ], [ $endereco ], [new TLabel('Número') ], [ $numero ] );
  79. $this->form->addFields( [ new TLabel('Complem') ], [ $complem ], [new TLabel('Bairro') ], [ $bairro ] );
  80. $this->form->addFields( [ new TLabel('Cidade') ], [ $cidade ], [ new TLabel('UF') ], [ $uf ]);
  81. $this->form->addFields( [ new TLabel('CEP') ], [ $cep ], [ new TLabel('Telefone Fixo') ], [ $telefone ] );
  82. $this->form->addFields( [ new TLabel('Celular') ], [ $celular ], [ new TLabel('E-mail') ], [ $email ] );
  83. $this->form->addContent([ new TFormSeparator('Dados Bancários', '#18953c', '18', '#eeeeee')] );
  84. $this->form->addFields( [ new TLabel('Banco', 'red')], [$banco_id], [ new TLabel('Operação') ],[ $operacao ] );
  85. $this->form->addFields( [ new TLabel('Agencia', 'red')], [$agencia], [ new TLabel('Conta', 'red')],[ $conta] );
  86. // Aba Documentação
  87. $this->form->appendPage('Documentação');
  88. $this->form->addContent([ new TFormSeparator('Identidade', '#18953c', '18', '#eeeeee')] );
  89. $this->form->addFields( [ new TLabel('Número') ], [$rg], [ new TLabel('Data Expedição') ], [$rg_data], [ new TLabel('Emissor') ], [$rg_orgao]);
  90. $this->form->addContent([ new TFormSeparator('Carteira de Trabalho', '#18953c', '18', '#eeeeee')] );
  91. $this->form->addFields( [ new TLabel('Número') ], [$ct], [ new TLabel('Série') ], [$ct_serie]);
  92. $this->form->addFields( [ new TLabel('UF') ], [$ct_uf] , [ new TLabel('Data') ], [$ct_data]);
  93. $this->form->addContent([ new TFormSeparator('Titulo Eleitoral', '#18953c', '18', '#eeeeee')] );
  94. $this->form->addFields( [ new TLabel('Número') ], [$titulo], [ new TLabel('Zona') ], [$titulo_zona]);
  95. $this->form->addFields( [ new TLabel('Seção') ], [$titulo_secao] , [ new TLabel('Cidade/UF') ], [$titulo_cidade]);
  96. $this->form->addContent([ new TFormSeparator('PIS/PASEP', '#18953c', '18', '#eeeeee')] );
  97. $this->form->addFields( [ new TLabel('Número') ], [$pis_pasep], [ new TLabel('Data Emissão') ], [$pis_pasep_data]);
  98. $this->form->addContent([ new TFormSeparator('Outros', '#18953c', '18', '#eeeeee')] );
  99. $this->form->addFields( [ new TLabel('Registro Profissional') ], [$reg_profissional], [ new TLabel('CNH') ], [$cnh]);
  100. // Cursos
  101. $this->form->appendPage('Cursos');
  102. $curso_id = new TDBUniqueSearch('curso_id[]', 'sispessoal', 'Curso', 'id', 'nome', 'nome');
  103. $curso_id->setSize('100%');
  104. $this->cursos = new TFieldList;
  105. $this->cursos->addField( '<b>Curso</b>', $curso_id);
  106. $this->form->addField($curso_id);
  107. //$this->cursos->enableSorting();
  108. $this->form->addContent( [ $this->cursos ] );
  109. $this->form->appendPage('Especializações');
  110. $this->form->appendPage('Histórico Admissional');
  111. // Aba Outras informações
  112. $this->form->appendPage('Outras informações');
  113. $this->form->addFields( [ new TLabel('Pendências') ], [$pendencias]);
  114. $this->form->addFields( [ new TLabel('Observações') ], [$obs]);
  115. if (!empty($id))
  116. {
  117. $id->setEditable(FALSE);
  118. }
  119. // create the form actions
  120. $btn = $this->form->addAction(_t('Save'), new TAction(array($this, 'onSave')), 'fa:floppy-o');
  121. $btn->class = 'btn btn-sm btn-primary';
  122. $this->form->addAction(_t('New'), new TAction(array($this, 'onClear')), 'bs:plus-sign green');
  123. $this->form->addAction( 'Listagem de Funcionários', new TAction(array('FuncionarioList', 'onReload')), 'fa:table blue' );
  124. // vertical box container
  125. $container = new TVBox;
  126. $container->style = 'width: 100%';
  127. $container->add( $this->form);
  128. parent::add($container);
  129. }
  130. /**
  131. * Save form data
  132. * @param $param Request
  133. */
  134. public function onSave( $param )
  135. {
  136. try
  137. {
  138. TTransaction::open('sispessoal'); // open a transaction
  139. $this->form->validate(); // validate form data
  140. $object = new Funcionario; // create an empty object
  141. $data = $this->form->getData(); // get form data as array
  142. $object->fromArray( (array) $data); // load the object with data
  143. $object->store(); // save the object
  144. // get the generated id
  145. $data->id = $object->id;
  146. $this->form->setData($data); // fill form data
  147. TTransaction::close(); // close the transaction
  148. new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
  149. }
  150. catch (Exception $e) // in case of exception
  151. {
  152. new TMessage('error', $e->getMessage()); // shows the exception error message
  153. $this->form->setData( $this->form->getData() ); // keep form data
  154. TTransaction::rollback(); // undo all pending operations
  155. }
  156. }
  157. /**
  158. * Clear form data
  159. * @param $param Request
  160. */
  161. public function onClear( $param )
  162. {
  163. $this->form->clear(TRUE);
  164. $this->cursos->addHeader();
  165. $this->cursos->addDetail( new stdClass );
  166. $this->cursos->addCloneAction();
  167. }
  168. /**
  169. * Load object to form data
  170. * @param $param Request
  171. */
  172. public function onEdit( $param )
  173. {
  174. try
  175. {
  176. if (isset($param['key']))
  177. {
  178. $key = $param['key']; // get the parameter $key
  179. TTransaction::open('sispessoal'); // open a transaction
  180. $object = new Funcionario($key); // instantiates the Active Record
  181. $cursos = $object->getCursos();
  182. if ($cursos)
  183. {
  184. $this->cursos->addHeader();
  185. foreach ($cursos as $curso)
  186. {
  187. $curso_detail = new stdClass;
  188. $curso_detail->curso_id = $curso->id;
  189. $this->cursos->addDetail($curso_detail);
  190. }
  191. $this->cursos->addCloneAction();
  192. }
  193. else
  194. {
  195. $this->onClear($param);
  196. }
  197. $this->form->setData($object); // fill the form
  198. TTransaction::close(); // close the transaction
  199. }
  200. else
  201. {
  202. $this->form->clear(TRUE);
  203. }
  204. }
  205. catch (Exception $e) // in case of exception
  206. {
  207. new TMessage('error', $e->getMessage()); // shows the exception error message
  208. TTransaction::rollback(); // undo all pending operations
  209. }
  210. }
  211. }
  212. ?>

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

Se o campo já está com 100% pode ser que o container pai não esteja.
 
  1. <?php
  2. $this->cursos->style = 'width:100%';
  3. ?>
CJ

Nataniel,

Obrigado pela resposta. Acrescentei também o código abaixo e ficou tudo certo.

 
  1. <?php
  2. $curso_id->setSize('100%');
  3. ?>