JA
exemplo tdbcombo do tutor não funcionou na minha aplicação
Fechado
Consigo escolher o combo, botão salvar mostra uma mensagem com o combo vazio
código :
código :
- <?php
- /**
- * unidadesForm Registration
- * @author <your name here>
- */
- class teste extends TPage
- {
- private $form;
- /**
- * Class constructor
- * Creates the page
- */
- function __construct()
- {
- parent::__construct();
- // create the form
- $this->form = new TForm;
- $this->form->class = 'tform';
- // creates the form field container
- $table = new TTable;
- $table->width = '100%';
- $this->form->add($table);
- // title row
- $table->addRowSet( new TLabel('Automatic selections'), '' )->class='tformtitle';
- // create the form fields
- $combo = new TDBCombo('imoveis', 'facilita', 'imoveis', 'id', 'resumo');
- $combo->setValue(2);
- $combo->setSize(160);
- // add the fields to the table
- $table->addRowSet(new TLabel('TDBCombo:'), $combo );
- // creates the action button
- $button1=new TButton('action1');
- // define the button action
- $button1->setAction(new TAction(array($this, 'onSave')), 'Save');
- $button1->setImage('ico_save.png');
- $table->addRowSet( $button1, '' )->class = 'tformaction';
- // define wich are the form fields
- $this->form->setFields(array($combo, $button1));
- // wrap the page content using vertical box
- $vbox = new TVBox;
- $vbox->add($this->form);
- parent::add($vbox);
- }
- /**
- * Simulates an save button
- * Show the form content
- */
- public function onSave($param)
- {
- $data = $this->form->getData(); // optional parameter: active record class
- // put the data back to the form
- $this->form->setData($data);
- // creates a string with the form element's values
- $message = 'Combo : ' . $data->combo . '<br>';
- // grava resultado
- // TSession::setValue('id_imovel', '1');
- TSession::setValue('lbl_imovel', $data->combo);
- // show the message
- new TMessage('info', $message);
- }
- }
- ?>
o TDBCombo serve para buscar dados de um Banco de Dados e deve ser usado dessa forma:
já a TCombo utiliza assim:
Outra coisa na hora de exibir, vc está indicando o nome da variável errado:
o certo é indicar o nome do campo
Obrigado, resolvido!
Como faço agora para fazer um filtro para mostrar somente os registros referentes aquela empresa?
O combo seleciona a empresa que desejo trabalhar e quando abrir a classe pessoas, ela deve listar as pessoas que tem o campo id_empresa igual a escolhida no combo...
Onde coloco esse filtro? tem algum modelo no tutor ?
o adianti tutor tem um exemplo para esse caso...
vc cria o evento onChange para a combo empresa
depois cria a função onChange que receberá o 'id' da empresa e carregará os funcionários a qual estão ligados
segue o link: www.adianti.com.br/framework_files/tutor/index.php?class=FormInterac