Lançado Adianti Framework 7.6!
Clique aqui para saber mais
setValue() não está funcionando para mim Caros, estou tentando usar o método setValue e não está funcionando. O que estou fazendo de errado ? Segue abaixo a forma que uso: $start_time = new TEntry('start_time'); $start_time->setValue('00:00:00'); $start_time->setSize(40); Abraços...
UP
setValue() não está funcionando para mim  
Fechado
Caros, estou tentando usar o método setValue e não está funcionando. O que estou fazendo de errado ?

Segue abaixo a forma que uso:

$start_time = new TEntry('start_time');
$start_time->setValue('00:00:00');
$start_time->setSize(40);

Abraços

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 (14)


MG

Tenta '00:40:00'
UP

Oi Marcelo, realmente não funciona, nem assim: '00:40:00'
MG

Udson

Posta o código completo do "control" para podermos ver....

Por que deveria funcionar.....
UP

public function __construct()
{
parent::__construct();

if (TSession::getValue('logged') !== TRUE)
{
throw new Exception(_t('Not logged'));
}

new TSession;
$panel = new TPanel(950, 600);
$this->form = new TForm('filter_form');
//
$this->formt = new TForm('form-title');
$this->formt->class = 'tform';
$tablet = new TTable;
$tablet->width = '100%';
$this->formt->add($tablet);
$tablet->addRowSet(new TLabel('Histórico de ligações'), '')->class='tformtitle';

$start_date = new TDate('start_date');
$start_date->setMask('yyyy-mm-dd');
$start_date->setSize(80);


$start_time_hour = new TCombo('start_time_hour');
$start_time_item_hour = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24');
$start_time_hour->addItems($start_time_item_hour);
$start_time_hour->setSize(45);
$start_time_hour->setValue('');

$start_time_min = new TCombo('start_time_min');
$start_time_item_min = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59');
$start_time_min->addItems($start_time_item_min);
$start_time_min->setSize(45);
$start_time_min->setValue('');

$end_date = new TDate('end_date');
$end_date->setMask('yyyy-mm-dd');
$end_date->setSize(80);

$end_time_hour = new TCombo('end_time_hour');
$end_time_item_hour = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24');
$end_time_hour->addItems($end_time_item_hour);
$end_time_hour->setSize(45);
$end_time_hour->setValue('');

$end_time_min = new TCombo('end_time_min');
$end_time_item_min = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59');
$end_time_min->addItems($end_time_item_min);
$end_time_min->setSize(45);
$end_time_min->setValue('');

$type = new TCombo('type');
$type_item= array('L' => 'Lembrete', 'C' => 'Confirmação');
$type->addItems($type_item);
$type->setSize(100);

$status = new TCombo('status');
$status_item= array('calls_queue' => 'Em fila',
'calls_confirmed' => 'Confirmado',
'calls_canceled' => 'Cancelado',
'calls_rescheduled' => 'Reagendado',
'calls_success' => 'Lig. c/ sucesso',
'calls_unsuccessfully' => 'Lig. s/ sucesso');

$status->addItems($status_item);
$status->setSize(120);

$retry = new TDBCombo('retry','easycontact','Cdr','retry','retry');
$retry->setSize(40);

$disposition = new TDBCombo('disposition','easycontact','Cdr','disposition','disposition');
$disposition->setSize(110);

$cod = new TEntry('cod');
$cod->setSize(70);

$nome_paciente = new TDBMultiSearch('nome_paciente','easycontact','Contact','nome_paciente','nome_paciente');
$nome_paciente->setSize(200);
$nome_paciente->setMinLength(2);
$nome_paciente->setMaxSize(1);
$nome_paciente->setOperator('like');

//$nome_paciente = new TEntry('nome_paciente');

$phone = new TCombo('phone');
$phone_opt = $phone_opt = array(1 => 1 , 2 => 2 , 3 => 3 , 4 => 4);
$phone->addItems($phone_opt);
$phone->setSize(35);

$dialed_number = new TEntry('dialed_number');
$dialed_number->setSize(90);

$phone_number = new TEntry('phone_number');
$phone_number->setSize(90);

$output_type = new TRadioGroup('output_type');
$output_options = array('pdf' => 'PDF', 'csv' => 'CSV');
$output_type->addItems($output_options);
$output_type->setValue('pdf');
$output_type->setLayout('horizontal');

$generate=new TButton('generate');
$generate->setAction(new TAction(array($this, 'onGenerate')), 'Gerar');
$generate->setImage('ico_print.png');

$table1 = new TTable;
$row1_tb1 = $table1->addRow();
$row2_tb1 = $table1->addRow();
$row3_tb1 = $table1->addRow();

$table2 = new TTable;
$row = $table2->addRow();
$row->addMultiCell('De :', $start_date,$start_time_hour,$start_time_min, 'Até :', $end_date,$end_time_hour,$end_time_min, 'Tipo :', $type, 'Status :', $status, 'Tentativa :', $retry);

$table3 = new TTable;
$row = $table3->addRow();
$row->addMultiCell('Disp. :', $disposition,'Paciente :', $nome_paciente,'Núm. discado :', $dialed_number,'Telefone :', $phone, 'Número :', $phone_number);

$table4 = new TTable;
$row = $table4->addRow();
$row->addMultiCell('Cod. :',$cod,$output_type,$generate);

$cell1_tb1 = $row1_tb1->addCell($table2);
$cell2_tb1 = $row2_tb1->addCell($table3);
$cell3_tb1 = $row3_tb1->addCell($table4);

$this->form->add($table1);

$find=new TButton('find');
$find->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
$find->setImage('ico_find.png');

/*
$button2=new TButton('csv');
$button2->setAction(new TAction(array($this, 'onExportCSV')), 'CSV');
$button2->setImage('ico_print.png');

$button3=new TButton('pdf');
$button3->setAction(new TAction(array($this, 'onExportPDF')), 'PDF');
$button3->setImage('ico_print.png');
*/

//$new=new TButton('new');
//$new->setAction(new TAction(array('CdrForm', 'onEdit' )), _t('New'));
//$new->setImage('ico_new.png');

/*
$row->addCell($button1);
$row->addCell($button2);
$row->addCell($button3);
$row->addCell($button4);
*/

$row->addCell($find);
//$row->addCell($new);

//$this->form->setFields(array($start_date, $end_date, $type, $status, $retry, $disposition, $nome_paciente, $phone, $phone_number, $button1, $button2, $button3, $button4));
$this->form->setFields(array($start_date,$start_time_hour,$start_time_min,$end_date,$end_time_hour,$end_time_min,$type,$status,$retry,$disposition,$cod,$nome_paciente,$phone,$phone_number,$find,$output_type,$generate,$dialed_number /*,$new */));

// creates a DataGrid
$this->datagrid = new TQuickGrid;
$this->datagrid->setHeight(400);
$this->datagrid->makeScrollable();

$dg_cod = $this->datagrid->addQuickColumn('Cod.', 'id', 'center', 60/*, new TAction(array($this, 'onReload')), array('order', 'calldate')*/);
$dg_calldate = $this->datagrid->addQuickColumn('Data / Hora', 'calldate', 'center', 60/*, new TAction(array($this, 'onReload')), array('order', 'calldate')*/);
$dg_patient = $this->datagrid->addQuickColumn(_t('Patient'), 'nome_paciente', 'left', 100, new TAction(array($this, 'onReload')), array('order', 'nome_paciente'));
$dg_dialed_number = $this->datagrid->addQuickColumn('Núm. discado', 'dialed_number', 'left', 83/*, new TAction(array($this, 'onReload')), array('order', 'dialed_number')*/);
$this->datagrid->addQuickColumn(_t('Phone') . '1', 'telefone1', 'left', 83, new TAction(array($this, 'onReload')), array('order', 'telefone1'));
$this->datagrid->addQuickColumn(_t('Phone'). '2', 'telefone2', 'left', 83, new TAction(array($this, 'onReload')), array('order', 'telefone2'));
$this->datagrid->addQuickColumn(_t('Phone'). '3', 'telefone3', 'left', 83, new TAction(array($this, 'onReload')), array('order', 'telefone3'));
$this->datagrid->addQuickColumn(_t('Phone'). '4', 'telefone4', 'left', 83, new TAction(array($this, 'onReload')), array('order', 'telefone4'));
$dg_type = $this->datagrid->addQuickColumn(_t('Type'), 'tipo', 'left', 60, new TAction(array($this, 'onReload')), array('order', 'tipo'));
$dg_status = $this->datagrid->addQuickColumn(_t('Status'), 'status', 'left', 40, new TAction(array($this, 'onReload')), array('order', 'status'));
$this->datagrid->addQuickColumn(_t('Retry'), 'retry', 'left', 40, new TAction(array($this, 'onReload')), array('order', 'retry'));
$this->datagrid->addQuickColumn(_t('Disposition'), 'disposition', 'left', 50, new TAction(array($this, 'onReload')), array('order', 'disposition'));

$dg_dialed_number->setTransformer(array($this,'transformerDialedNumber'));
$dg_calldate->setTransformer(array($this,'transformerDataCarga'));
$dg_patient->setTransformer(array($this,'transformerPatient'));
$dg_type->setTransformer(array($this,'transformerType'));
$dg_status->setTransformer(array($this,'transformerStatus'));



//$this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array('CdrForm', 'onEdit')), 'id', 'ico_edit.png');
//$this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');

$this->datagrid->createModel();

$this->datagrid_footer = new TQuickGrid;
$this->datagrid_footer->addQuickColumn('', 'total_records', 'left', 800);
$this->datagrid_footer->addQuickColumn('', 'count', 'right', 150);
$this->datagrid_footer->createModel();

$this->pageNavigation = new TPageNavigation;
$this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
$this->pageNavigation->setWidth($this->datagrid->getWidth());

$vbox = new TVBox;
$vbox->add($this->formt);
$vbox->add($this->form);
$vbox->add($this->datagrid);
$vbox->add('<br />');
$vbox->add($this->datagrid_footer);
$vbox->add($this->pageNavigation);
$panel->put($vbox,0, 0);
parent::add($panel);
}
MG

Udson
Nenhum setValue está funcionando, ou apenas este que vc menciona?
UP

Nehum valor funciona, vazio ou nao.
MG

Estranho.

Desculpe as perguntas, mas é importante para tentarmos identificar o que pode estar acontecendo.

Você tem outros controles? Eles estão funcionando?

Vou tentar implementar uma parte do que você fez e validar.
Por que comigo está ok.
Talvez não consiga ver isso hoje, mas assim que consegui eu te aviso.
Se neste intermédio algum colega da lista, responder legal.
UP

Blz Marcelo, surgiu a necessidade de usar hoje, eu já usei antes em outro projeto e funcionou.
MG

Udson

Eu criei um controle e copiei parte do seu código de criação de objetos e funcionou?

Galera da lista, vocês já passaram por isso?

O que poderia ser esta inconsistência?

Abraços
MG

Desculpe, a frase seria uma exclumação "!" e não interrogação "?".
PD

Aqui foi tranquilo.

Se o componente for TCombo, você precisa passar o índice do elemento, não o elemento em si:

  1. <?php
  2. $start_time_hour = new TCombo('start_time_hour'); 
  3. $start_time_item_hour = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'); 
  4. $start_time_hour->addItems($start_time_item_hour); 
  5. $start_time_hour->setSize(45); 
  6. $start_time_hour->setValue(1); 
  7. $start_time_min = new TCombo('start_time_min'); 
  8. $start_time_item_min = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59'); 
  9. $start_time_min->addItems($start_time_item_min); 
  10. $start_time_min->setSize(45); 
  11. $start_time_min->setValue(12); 
  12. ?>


Fica a dica, faz um for para popular a hora...

  1. <?php
  2. for ($n=1$n<=24$n++)
  3. {
  4.     $itens[$n] = str_pad($n2'0'STR_PAD_LEFT);
  5. }
  6. ?>


Att,
Pablo
R

Retomando o tópico, eu tive o mesmo problema.
Identifiquei que a diferença entre quando funciona o setValue e quando não funciona é devido a utilização da classe TStandardForm.
Identifiquei que se eu editar o método onEdit, e comentar a linha "$this->form->clear();" que é executada quando o método onEdit não recebe nenhum objeto para popular o formulário o método setValue funciona, quando deixo descomentada ele não funciona. Claro, isso se deve pelo fato de que o método limpa o formulário, inclusive os valores setados pelo "setValue". Mas fica a pergunta, como utilizar setValue, utilizando a classe TStandardForm sem ter que mexer no framework? Ou eu que estou fazendo algo errado.

abraço!
PD

Hugo,

Vincule o botão "Novo" à outro método (Ex: onClear) no lugar do onEdit();

$this->form->addQuickAction('New', new TAction(array($this, 'onClear')), 'ico_new.png');

E no onClear(), execute o $this->form->clear();

Abs,
R

Claro, ótima ideia! Valeu mesmo. A propósito, ótimo o Framework, muito produtivo.