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
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
- <?php
- <?php
- /**
- * FuncionarioForm Form
- * @author <your name here>
- */
- class FuncionarioForm extends TPage
- {
- protected $form; // form
- private $cursos;
- /**
- * Form constructor
- * @param $param Request
- */
- public function __construct( $param )
- {
- parent::__construct();
- // creates the form
- $this->form = new BootstrapFormBuilder('form_Funcionario');
- $this->form->setFormTitle('Funcionário');
- // create the form fields
- $id = new THidden('id');
- $nome = new TEntry('nome');
- $endereco = new TEntry('endereco');
- $numero = new TEntry('numero');
- $complem = new TEntry('complem');
- $bairro = new TEntry('bairro');
- $cidade = new TEntry('cidade');
- $uf = new TEntry('uf');
- $cep = new TEntry('cep');
- $nacionalidade = new TEntry('nacionalidade');
- $naturalidade = new TEntry('naturalidade');
- $uf_natural = new TEntry('uf_natural');
- $data_nascimento = new TDate('data_nascimento');
- $telefone = new TEntry('telefone');
- $celular = new TEntry('celular');
- $email = new TEntry('email');
- $sexo = new TEntry('sexo');
- $estadocivil = new TEntry('estadocivil');
- $racacor = new TEntry('racacor');
- $pai = new TEntry('pai');
- $mae = new TEntry('mae');
- $grauinstrucao_id = new TCombo('grauinstrucao_id');
- $rg = new TEntry('rg');
- $rg_data = new TDate('rg_data');
- $rg_orgao = new TEntry('rg_orgao');
- $cpf = new TEntry('cpf');
- $ct = new TEntry('ct');
- $ct_serie = new TEntry('ct_serie');
- $ct_uf = new TEntry('ct_uf');
- $ct_data = new TDate('ct_data');
- $reg_profissional = new TEntry('reg_profissional');
- $cnh = new TEntry('cnh');
- $titulo = new TEntry('titulo');
- $titulo_zona = new TEntry('titulo_zona');
- $titulo_secao = new TEntry('titulo_secao');
- $titulo_cidade = new TEntry('titulo_cidade');
- $pis_pasep = new TEntry('pis_pasep');
- $pis_pasep_data = new TDate('pis_pasep_data');
- $obs = new TText('obs');
- $pendencias = new TText('pendencias');
- $ativo = new TEntry('ativo');
- $banco_id = new TEntry('banco_id');
- $agencia = new TEntry('agencia');
- $conta = new TEntry('conta');
- $operacao = new TEntry('operacao');
- // Aba Dados Gerais
- $this->form->appendPage('Dados Gerais');
- $this->form->addContent([ new TFormSeparator('Funcionário', '#18953c', '18', '#eeeeee')] );
- $this->form->addFields( [ $id]);
- $this->form->addFields( [ new TLabel('Ativo')], [$ativo], [new TLabel('CPF', 'red')], [$cpf] );
- $this->form->addFields( [ new TLabel('Nome', 'red')], [$nome] );
- $this->form->addFields( [ new TLabel('Data Nasc') ], [ $data_nascimento ], [new TLabel('Sexo') ], [ $sexo ] );
- $this->form->addFields( [ new TLabel('Raça/Cor') ], [ $racacor ], [new TLabel('Estado Civil') ], [ $estadocivil ] );
- $this->form->addFields( [ new TLabel('Naturalidade') ], [ $naturalidade], [ new TLabel('UF') ], [ $uf_natural ] );
- $this->form->addContent([ new TFormSeparator('Filiação', '#18953c', '18', '#eeeeee')] );
- $this->form->addFields( [ new TLabel('Nome Pai') ], [ $pai ], [ new TLabel('Nome Mãe') ], [ $mae ] );
- $this->form->addContent([ new TFormSeparator('Endereço', '#18953c', '18', '#eeeeee')] );
- $this->form->addFields( [ new TLabel('Endereço') ], [ $endereco ], [new TLabel('Número') ], [ $numero ] );
- $this->form->addFields( [ new TLabel('Complem') ], [ $complem ], [new TLabel('Bairro') ], [ $bairro ] );
- $this->form->addFields( [ new TLabel('Cidade') ], [ $cidade ], [ new TLabel('UF') ], [ $uf ]);
- $this->form->addFields( [ new TLabel('CEP') ], [ $cep ], [ new TLabel('Telefone Fixo') ], [ $telefone ] );
- $this->form->addFields( [ new TLabel('Celular') ], [ $celular ], [ new TLabel('E-mail') ], [ $email ] );
- $this->form->addContent([ new TFormSeparator('Dados Bancários', '#18953c', '18', '#eeeeee')] );
- $this->form->addFields( [ new TLabel('Banco', 'red')], [$banco_id], [ new TLabel('Operação') ],[ $operacao ] );
- $this->form->addFields( [ new TLabel('Agencia', 'red')], [$agencia], [ new TLabel('Conta', 'red')],[ $conta] );
- // Aba Documentação
- $this->form->appendPage('Documentação');
- $this->form->addContent([ new TFormSeparator('Identidade', '#18953c', '18', '#eeeeee')] );
- $this->form->addFields( [ new TLabel('Número') ], [$rg], [ new TLabel('Data Expedição') ], [$rg_data], [ new TLabel('Emissor') ], [$rg_orgao]);
- $this->form->addContent([ new TFormSeparator('Carteira de Trabalho', '#18953c', '18', '#eeeeee')] );
- $this->form->addFields( [ new TLabel('Número') ], [$ct], [ new TLabel('Série') ], [$ct_serie]);
- $this->form->addFields( [ new TLabel('UF') ], [$ct_uf] , [ new TLabel('Data') ], [$ct_data]);
- $this->form->addContent([ new TFormSeparator('Titulo Eleitoral', '#18953c', '18', '#eeeeee')] );
- $this->form->addFields( [ new TLabel('Número') ], [$titulo], [ new TLabel('Zona') ], [$titulo_zona]);
- $this->form->addFields( [ new TLabel('Seção') ], [$titulo_secao] , [ new TLabel('Cidade/UF') ], [$titulo_cidade]);
- $this->form->addContent([ new TFormSeparator('PIS/PASEP', '#18953c', '18', '#eeeeee')] );
- $this->form->addFields( [ new TLabel('Número') ], [$pis_pasep], [ new TLabel('Data Emissão') ], [$pis_pasep_data]);
- $this->form->addContent([ new TFormSeparator('Outros', '#18953c', '18', '#eeeeee')] );
- $this->form->addFields( [ new TLabel('Registro Profissional') ], [$reg_profissional], [ new TLabel('CNH') ], [$cnh]);
- // Cursos
- $this->form->appendPage('Cursos');
- $curso_id = new TDBUniqueSearch('curso_id[]', 'sispessoal', 'Curso', 'id', 'nome', 'nome');
- $curso_id->setSize('100%');
- $this->cursos = new TFieldList;
- $this->cursos->addField( '<b>Curso</b>', $curso_id);
- $this->form->addField($curso_id);
- //$this->cursos->enableSorting();
- $this->form->addContent( [ $this->cursos ] );
- $this->form->appendPage('Especializações');
- $this->form->appendPage('Histórico Admissional');
- // Aba Outras informações
- $this->form->appendPage('Outras informações');
- $this->form->addFields( [ new TLabel('Pendências') ], [$pendencias]);
- $this->form->addFields( [ new TLabel('Observações') ], [$obs]);
- if (!empty($id))
- {
- $id->setEditable(FALSE);
- }
- // create the form actions
- $btn = $this->form->addAction(_t('Save'), new TAction(array($this, 'onSave')), 'fa:floppy-o');
- $btn->class = 'btn btn-sm btn-primary';
- $this->form->addAction(_t('New'), new TAction(array($this, 'onClear')), 'bs:plus-sign green');
- $this->form->addAction( 'Listagem de Funcionários', new TAction(array('FuncionarioList', 'onReload')), 'fa:table blue' );
- // vertical box container
- $container = new TVBox;
- $container->style = 'width: 100%';
- $container->add( $this->form);
- parent::add($container);
- }
- /**
- * Save form data
- * @param $param Request
- */
- public function onSave( $param )
- {
- try
- {
- TTransaction::open('sispessoal'); // open a transaction
- $this->form->validate(); // validate form data
- $object = new Funcionario; // create an empty object
- $data = $this->form->getData(); // get form data as array
- $object->fromArray( (array) $data); // load the object with data
- $object->store(); // save the object
- // get the generated id
- $data->id = $object->id;
- $this->form->setData($data); // fill form data
- TTransaction::close(); // close the transaction
- new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- $this->form->setData( $this->form->getData() ); // keep form data
- TTransaction::rollback(); // undo all pending operations
- }
- }
- /**
- * Clear form data
- * @param $param Request
- */
- public function onClear( $param )
- {
- $this->form->clear(TRUE);
- $this->cursos->addHeader();
- $this->cursos->addDetail( new stdClass );
- $this->cursos->addCloneAction();
- }
- /**
- * Load object to form data
- * @param $param Request
- */
- public function onEdit( $param )
- {
- try
- {
- if (isset($param['key']))
- {
- $key = $param['key']; // get the parameter $key
- TTransaction::open('sispessoal'); // open a transaction
- $object = new Funcionario($key); // instantiates the Active Record
- $cursos = $object->getCursos();
- if ($cursos)
- {
- $this->cursos->addHeader();
- foreach ($cursos as $curso)
- {
- $curso_detail = new stdClass;
- $curso_detail->curso_id = $curso->id;
- $this->cursos->addDetail($curso_detail);
- }
- $this->cursos->addCloneAction();
- }
- else
- {
- $this->onClear($param);
- }
- $this->form->setData($object); // fill the form
- TTransaction::close(); // close the transaction
- }
- else
- {
- $this->form->clear(TRUE);
- }
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- TTransaction::rollback(); // undo all pending operations
- }
- }
- }
- ?>
Se o campo já está com 100% pode ser que o container pai não esteja.
Nataniel,
Obrigado pela resposta. Acrescentei também o código abaixo e ficou tudo certo.