/** * Class constructor * Creates the page */ function __construct() { parent::__construct(); // create the form using TQuickForm class $this->form = new TQuickForm('form_dynamic_filter'); // create the notebook $notebook = new TNotebook(530, 160); // adds the notebook page $notebook->appendPage('Dynamic filtering', $this->form); $check_gender = new TCheckGroup('check_gender'); $check_gender->addItems(array('M' => 'Male', 'F' => 'Female')); $check_gender->setLayout('horizontal'); $combo_status = new TCombo('combo_status'); $combo_status->addItems(array('S' => 'Single', 'C' => 'Committed', 'M' => 'Married')); $combo_customers = new TCombo('customers'); // add the fields inside the form $this->form->addQuickField('Load customers: ', $check_gender, 200); $this->form->addQuickField('', $combo_status, 200); $this->form->addQuickField('', $combo_customers, 200); $check_gender->setChangeAction(new TAction(array($this, 'onGenderChange'))); $combo_status->setChangeAction(new TAction(array($this, 'onGenderChange'))); // wrap the page content using vertical box $vbox = new TVBox(); $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $vbox->add($notebook); parent::add($vbox); }
function onStep2() { try { $data = $this->form->getData(); $this->form->validate(); $page2 = new TTable(); $this->notebook->appendPage('Page 2', $page2); $gender_options = array('M' => 'Male', 'F' => 'Female'); $ocupation_optins = array('S' => 'Self employed', 'B' => 'Business', 'R' => 'Retired'); switch ($data->field1) { case 'combo': $field3 = new TCombo('field3'); break; case 'radio': $field3 = new TRadioGroup('field3'); $field3->setLayout('horizontal'); break; case 'check': $field3 = new TCheckGroup('field3'); $field3->setLayout('horizontal'); break; } $field3->addValidation('Field 3', new TRequiredValidator()); switch ($data->field2) { case '1': $label = 'Gender'; $field3->addItems($gender_options); break; case '2': $label = 'Ocupation'; $field3->addItems($ocupation_optins); break; } $field4 = new TEntry('field4'); $field4->addValidation('Field 4', new TRequiredValidator()); // add a row for one field $row = $page2->addRow(); $row->addCell($l3 = new TLabel($label . ':')); $cell = $row->addCell($field3); // add a row for one field $row = $page2->addRow(); $row->addCell($l4 = new TLabel('Next tab title:')); $cell = $row->addCell($field4); $l3->setFontColor('#FF0000'); $l4->setFontColor('#FF0000'); // creates the action button $button2 = new TButton('action2'); $button2->setAction(new TAction(array($this, 'onStep3')), 'Next'); $button2->setImage('ico_next.png'); $row = $page2->addRow(); $row->addCell($button2); $this->form->addField($field3); $this->form->addField($field4); $this->form->addField($button2); $this->notebook->setCurrentPage(1); $this->form->setData($data); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
/** * Class Constructor * @param $name widget's name * @param $database database name * @param $model model class name * @param $key table field to be used as key in the combo * @param $value table field to be listed in the combo */ public function __construct($name, $database, $model, $key, $value) { // executes the parent class constructor parent::__construct($name); // carrega objetos do banco de dados TTransaction::open($database); // instancia um repositório de Estado $repository = new TRepository($model); $criteria = new TCriteria(); $criteria->setProperty('order', $key); // carrega todos objetos $collection = $repository->load($criteria); // adiciona objetos na combo if ($collection) { $items = array(); foreach ($collection as $object) { $items[$object->{$key}] = $object->{$value}; } parent::addItems($items); } TTransaction::close(); }
/** * on ChangeRadio change * @param $param Action parameters */ public static function onChangeRadio($param) { if ($param['enable'] == 1) { TCombo::enableField('form_enable_disable', 'block1_combo'); TEntry::enableField('form_enable_disable', 'block1_entry'); TSpinner::enableField('form_enable_disable', 'block1_spinner'); TDate::disableField('form_enable_disable', 'block2_date'); TEntry::disableField('form_enable_disable', 'block2_entry'); TCheckGroup::disableField('form_enable_disable', 'block2_check'); TDate::clearField('form_enable_disable', 'block2_date'); TEntry::clearField('form_enable_disable', 'block2_entry'); TCheckGroup::clearField('form_enable_disable', 'block2_check'); } else { TCombo::disableField('form_enable_disable', 'block1_combo'); TEntry::disableField('form_enable_disable', 'block1_entry'); TSpinner::disableField('form_enable_disable', 'block1_spinner'); TDate::enableField('form_enable_disable', 'block2_date'); TEntry::enableField('form_enable_disable', 'block2_entry'); TCheckGroup::enableField('form_enable_disable', 'block2_check'); TCombo::clearField('form_enable_disable', 'block1_combo'); TEntry::clearField('form_enable_disable', 'block1_entry'); TSpinner::clearField('form_enable_disable', 'block1_spinner'); } }
$form = new TForm('form_pessoas'); // instancia uma tabela $table = new TTable(); // define algumas propriedades da tabela $table->bgcolor = '#f0f0f0'; $table->style = 'border:2px solid grey'; $table->width = 400; // adiciona a tabela ao formulário $form->add($table); // cria os campos do formulário $codigo = new TEntry('id'); $nome = new TEntry('nome'); $endereco = new TEntry('endereco'); $datanasc = new TEntry('datanasc'); $sexo = new TRadioGroup('sexo'); $linguas = new TCheckGroup('linguas'); $qualifica = new TText('qualifica'); // define tamanho para campo código $codigo->setSize(100); // define como somente leitura $codigo->setEditable(FALSE); // cria um vetor com as opções de sexo $items = array(); $items['M'] = 'Masculino'; $items['F'] = 'Feminino'; // define tamanho para campo data de nascimento $datanasc->setSize(100); // adiciona as opções ao radio button $sexo->addItems($items); // define a opção ativa $sexo->setValue('M');
/** * */ public function makeTCheckGroup($properties) { $widget = new TCheckGroup((string) $properties->{'name'}); $widget->setLayout('vertical'); $pieces = explode("\n", (string) $properties->{'items'}); $items = array(); if ($pieces) { foreach ($pieces as $line) { $part = explode(':', $line); $items[$part[0]] = $part[1]; } } $widget->addItems($items); if (isset($properties->{'value'})) { $widget->setValue(explode(',', (string) $properties->{'value'})); } if (isset($properties->{'tip'})) { $widget->setTip((string) $properties->{'tip'}); } $this->fields[] = $widget; $this->fieldsByName[(string) $properties->{'name'}] = $widget; return $widget; }
function __construct() { parent::__construct(); $table = new TTable(); $table->style = "width:100%"; $frame_proprietarios = new TFrame(); $frame_proprietarios->setLegend('Proprietarios'); $frame_inf = new TFrame(); $frame_inf->setLegend('Informações do Logradouro'); $this->form = new TForm('form_Imovel'); $this->form->class = 'tform'; $this->form->add($table); $table->addRowSet(new TLabel('Imóvel'), '', '', '')->class = 'tformtitle'; $imovel_id = new TEntry('imovel_id'); $logradouro = new TEntry('logradouro'); $numero = new TEntry('numero'); $quadra = new TEntry('quadra'); $lote = new TEntry('lote'); $multifield1 = new TMultiField('proprietarios'); $proprietarios_id = new TDBSeekButton('proprietarios_id', 'liger', 'form_Imovel', 'Contribuinte', 'contribuinte_nome', 'proprietarios_proprietarios_id', 'proprietarios_contribuinte_nome'); $contribuinte_nome = new TEntry('contribuinte_nome'); $inflogradouro = new TCheckGroup('inflogradouro'); $inflogradouro->addItems(array('1' => 'Pavimentação ', '2' => 'Meio Fio ', '3' => 'Galerias Pluviais ', '4' => 'Arborização ', '5' => 'Rede Elétrica ', '6' => 'Inluminação Pública ', '7' => 'Rede D\'Água ', '8' => 'Rede de Esgoto ', '9' => 'Coleta de Lixo ')); $inflogradouro->setLayout('horizontal'); $tipopropriedade = new TCombo('tipopropriedade'); $tipopropriedade->addItems(array('1' => 'Particular', '2' => 'Municipal', '3' => 'Estadual', '4' => 'Federal', '5' => 'Religiosa')); $situacaojuridica = new TCombo('situacaojuridica'); $situacaojuridica->addItems(array('1' => 'Plena', '2' => 'Poseiro', '3' => 'Aforamento', '4' => 'Litigiosa')); $localizacao = new TCombo('localizacao'); $localizacao->addItems(array('1' => 'Esquina', '2' => 'Encravado', '3' => 'Meio de Quadra', '4' => 'Toda Quadra', '5' => 'Gleba')); $ocupacao = new TCombo('ocupacao'); $ocupacao->addItems(array('1' => 'Vago', '2' => 'Edificado', '3' => 'Edificação Temporaria', '4' => 'Edificação em Construção', '5' => 'Construção Paralizada', '6' => 'Edificação em Demolição', '7' => 'Edificação em Ruinas', '8' => 'Praça')); $numfrentes = new TEntry('numfrentes'); $utilizacao = new TCombo('utilizacao'); $utilizacao->addItems(array('1' => 'Própria', '2' => 'Alugada', '3' => 'Cedida', '4' => 'Desocupada', '5' => 'Fechada')); $tipo = new TCombo('tipo'); $tipo->addItems(array('1' => 'Casa', '2' => 'Apartamento', '3' => 'Sala', '4' => 'Loja', '5' => 'Galpão')); $douso = new TCombo('douso'); $douso->addItems(array('1' => 'Residencial', '2' => 'Comercial', '3' => 'Industrial', '4' => 'Religioso', '5' => 'Administração Pública', '6' => 'Serviços')); $agua = new TCombo('agua'); $agua->addItems(array('1' => 'Sem', '2' => 'Cisterna', '3' => 'Com Pena DÁgua', '4' => 'Hidrometro')); $esgoto = new TCombo('esgoto'); $esgoto->addItems(array('1' => 'Sem', '2' => 'Fossa Negra', '3' => 'Fossa Septica', '4' => 'Rede Pública')); $areaterreno = new TEntry('areaterreno'); $testada = new TEntry('testada'); $areaedificada = new TEntry('areaedificada'); $areatotaledificada = new TEntry('areatotaledificada'); $imgimovel = new TEntry('imgimovel'); $frame_proprietarios->add($multifield1); $multifield1->setHeight(140); $multifield1->setClass('Proprietarios'); $multifield1->addField('proprietarios_id', 'Contribuinte' . ' ID', $proprietarios_id, 100, true); $multifield1->addField('contribuinte_nome', 'Nome', $contribuinte_nome, 250); $multifield1->setOrientation('horizontal'); $imovel_id->setEditable(false); $contribuinte_nome->setEditable(false); $imovel_id->setSize(100); $logradouro->setSize(250); $quadra->setSize(100); $lote->setSize(100); $numero->setSize(100); $numfrentes->setSize(100); $table->addRowSet(new TLabel('ID:'), $imovel_id, new TLabel('Logradouro: '), $logradouro); $table->addRowSet(new TLabel('Quadra: '), $quadra, new TLabel('Lote: '), $lote); $table->addRowSet(new TLabel('Número: '), $numero, new TLabel('Nº de Frentes: '), $numfrentes); $table->addRowSet(new TLabel('Propriedade: '), $tipopropriedade, new TLabel('Situação Juridica: '), $situacaojuridica); $table->addRowSet(new TLabel('Localização: '), $localizacao, new TLabel('Ocupação: '), $ocupacao); $table->addRowSet(new TLabel('Utilização: '), $utilizacao, new TLabel('Tipo: '), $tipo); $table->addRowSet(new TLabel('Do Uso: '), $douso, new TLabel('Água: '), $agua); $table->addRowSet(new TLabel('Esgoto: '), $esgoto); $table->addRowSet(new TLabel('Área do Terreno: '), $areaterreno); $table->addRowSet(new TLabel('Testada: '), $testada); $table->addRowSet(new TLabel('Área Edificada: '), $areaedificada); $table->addRowSet(new TLabel('Área Total Edificada: '), $areatotaledificada); $table->addRowSet(new TLabel('Imagem do Imóvel: '), $imgimovel); $frame_inf->add($inflogradouro); $row1 = $table->addRow(); $cell = $row1->addCell($frame_inf); $cell->colspan = 4; $row = $table->addRow(); $cell = $row->addCell($frame_proprietarios); $cell->colspan = 4; $save_button = new TButton('save'); $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save')); $save_button->setImage('ico_save.png'); $new_button = new TButton('new'); $new_button->setAction(new TAction(array($this, 'onEdit')), _t('New')); $new_button->setImage('ico_new.png'); $list_button = new TButton('list'); $list_button->setAction(new TAction(array('ImovelList', 'onReload')), _t('Back to the listing')); $list_button->setImage('ico_datagrid.png'); $this->form->setFields(array($imovel_id, $logradouro, $multifield1, $inflogradouro, $tipopropriedade, $situacaojuridica, $localizacao, $ocupacao, $numero, $quadra, $lote, $numfrentes, $utilizacao, $tipo, $douso, $agua, $esgoto, $areaterreno, $testada, $areaedificada, $areatotaledificada, $imgimovel, $save_button, $new_button, $list_button)); $buttons = new THBox(); $buttons->add($save_button); $buttons->add($new_button); $buttons->add($list_button); $container = new TTable(); $container->width = '80%'; $container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', 'ImovelList')); $container->addRow()->addCell($this->form); $row = $table->addRow(); $row->class = 'tformaction'; $cell = $row->addCell($buttons); $cell->colspan = 2; parent::add($container); }
/** * 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('Manual selections'), '')->class = 'tformtitle'; // create the form fields $radio = new TRadioGroup('radio'); $check = new TCheckGroup('check'); $combo = new TCombo('combo'); $select = new TSelect('select'); $search = new TMultiSearch('search'); $autocomp = new TEntry('autocomplete'); $search->setMinLength(3); $radio->setLayout('horizontal'); $check->setLayout('horizontal'); $combo->setSize(160); $select->setSize(200, 70); // open database transaction TTransaction::open('samples'); // items repository $repository = new TRepository('Category'); // load all objects $collection = $repository->load(new TCriteria()); // add the combo items $items = array(); foreach ($collection as $object) { $items[$object->id] = $object->name; } $radio->addItems($items); $check->addItems($items); $combo->addItems($items); $select->addItems($items); $search->addItems($items); $autocomp->setCompletion(array_values($items)); TTransaction::close(); // add the fields to the table $table->addRowSet(new TLabel('TRadioGroup:'), $radio); $table->addRowSet(new TLabel('TCheckGroup:'), $check); $table->addRowSet(new TLabel('TCombo:'), $combo); $table->addRowSet(new TLabel('TSelect:'), $select); $table->addRowSet(new TLabel('TMultiSearch:'), $search); $table->addRowSet(new TLabel('Autocomplete:'), $autocomp); // creates the action button $button1 = new TButton('action1'); $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($radio, $check, $combo, $select, $search, $autocomp, $button1)); // wrap the page content using vertical box $vbox = new TVBox(); $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $vbox->add($this->form); parent::add($vbox); }
/** * 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('Static selections'), '')->class = 'tformtitle'; // create the form fields $radio = new TRadioGroup('radio'); $check = new TCheckGroup('check'); $combo = new TCombo('combo'); $select = new TSelect('select'); $search = new TMultiSearch('search'); $autocomp = new TEntry('autocomplete'); $radio->setLayout('horizontal'); $check->setLayout('horizontal'); $combo->setSize(100); $select->setSize(200, 70); $search->setSize(300, 70); $items = array(); $items['a'] = 'Item a'; $items['b'] = 'Item b'; $items['c'] = 'Item c'; $radio->addItems($items); $check->addItems($items); $combo->addItems($items); $select->addItems($items); $search->addItems($items); $autocomp->setCompletion(array_values($items)); foreach ($radio->getLabels() as $key => $label) { $label->setTip("Radio {$key}"); } foreach ($check->getLabels() as $key => $label) { $label->setTip("Check {$key}"); } // define default values $search->setMinLength(3); $radio->setValue('a'); $check->setValue(array('a', 'c')); $combo->setValue('b'); $select->setValue(array('b', 'c')); $search->setValue(array('b' => 'Item b')); // add the fields to the table $table->addRowSet(new TLabel('TRadioGroup:'), $radio); $table->addRowSet(new TLabel('TCheckGroup:'), $check); $table->addRowSet(new TLabel('TCombo:'), $combo); $table->addRowSet(new TLabel('TSelect:'), $select); $table->addRowSet(new TLabel('TMultiSearch:'), $search); $table->addRowSet(new TLabel('Autocomplete:'), $autocomp); // creates the action button $button1 = new TButton('action1'); $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($radio, $check, $combo, $select, $search, $autocomp, $button1)); // wrap the page content using vertical box $vbox = new TVBox(); $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $vbox->add($this->form); parent::add($vbox); }