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

Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto 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. ?>