Conheça as melhorias da versão 8.0, 8.1, 8.2!
Clique aqui para saber mais
Alinhamento - Form Pessoal, Um novo help. Estou fazendo um formulário, que recebe um parâmetro e contém um TMultifield. Mas não consigo deixá-lo alinhado, na imagem em anexo, a primeira imagem é como está o formulário, eu gostaria de deixá-lo como na segunda. Fazer uma separação e deixar a tela mais bonita, jogar o TEntry pra cima, mas o campo não vai, ele fica la no canto direito da tela, com um...
FW
Alinhamento - Form  
Fechado
Pessoal,
Um novo help.

Estou fazendo um formulário, que recebe um parâmetro e contém um TMultifield.
Mas não consigo deixá-lo alinhado, na imagem em anexo, a primeira imagem é como está o formulário, eu gostaria de deixá-lo como na segunda.

Fazer uma separação e deixar a tela mais bonita, jogar o TEntry pra cima, mas o campo não vai, ele fica la no canto direito da tela, com uma separação enorme entre o Label e o TEntry.

Segue abaixo meu fonte:
 
  1. <?php
  2. class FormReembolso extends TPage
  3. {
  4. private $form;
  5. /**
  6. * Class constructor
  7. * Creates the page
  8. */
  9. function __construct()
  10. {
  11. parent::__construct();
  12. // create the form
  13. $this->form = new TForm('formReembolso');
  14. $this->form->class = 'tform';
  15. $table = new TTable;
  16. $table->style = "width: 420px";
  17. $this->form->add($table);
  18. // add a row for the form title
  19. $row = $table->addRow();
  20. $row->class = 'tformtitle'; // CSS class
  21. $cell = $row->addCell( new TLabel('Reembolso'));
  22. $cell->colspan = 4;
  23. $multifield = new TMultiField('reembolso');
  24. $multifield->setOrientation('horizontal');
  25. 2533_viagem = new TEntry('id_viagem');
  26. $valor = new TEntry('valor');
  27. $tipo_reembolso = new TDBCombo('tipo_reembolso', 'gestao_viagens', 'TipoReembolso', 'id_tipo_reembolso', 'tipo_reembolso');
  28. 2533_viagem->setEditable(FALSE);
  29. 2533_viagem->style = "margin-left: 12px";
  30. $tipo_reembolso->setSize(180);
  31. $multifield->setHeight(140);
  32. $multifield->addField('tipo_reembolso', 'Tipo', $tipo_reembolso, 160, TRUE);
  33. $multifield->addField('valor','Valor', $valor, 147, TRUE);
  34. 2533_viagem->setSize(65);
  35. $valor->setSize(120);
  36. $valor->setNumericMask(2, ',', '.');
  37. $valor->style = "margin-left: 9px";
  38. // add ID VIAGEM
  39. $row_id=$table->addRow();
  40. $lbl = new TLabel('Id Viagem');
  41. $row_id->addCell($lbl);
  42. $row_id=$table->addRow();
  43. $row_id->addCell(2533_viagem);
  44. // add a row for one field
  45. $row=$table->addRow();
  46. $row->addCell( $multifield )->style = "padding-left: 12px";
  47. // creates the action button
  48. $button1=new TButton('action1');
  49. // define the button action
  50. $button1->setAction(new TAction(array($this, 'onSave')), 'Salvar');
  51. $button1->setImage('ico_save.png');
  52. // add a row for the button
  53. $row=$table->addRow();
  54. $row->addCell($button1);
  55. // define wich are the form fields
  56. $this->form->setFields(array(2533_viagem, $multifield, $button1));
  57. // wrap the page content using vertical box
  58. $vbox = new TVBox;
  59. $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  60. $vbox->add($this->form);
  61. parent::add($vbox);
  62. }
  63. /**
  64. * Simulates an save button
  65. * Show the form content
  66. */
  67. public function onSave($param)
  68. {
  69. $data = $this->form->getData(); // optional parameter: active record class
  70. //var_dump($data);
  71. 2533_viagem = $data->id_viagem;
  72. // put the data back to the form
  73. $this->form->setData($data);
  74. $message = '';
  75. // get the tipo_reembolso
  76. if ($data->reembolso)
  77. {
  78. foreach ($data->reembolso as $contact)
  79. {
  80. $message .= 2533_viagem . ' - ' . $contact->valor . ' - ' . $contact->tipo_reembolso . '<br>';
  81. }
  82. }
  83. // show the message
  84. new TMessage('info', $message);
  85. }
  86. /**
  87. * method onEdit()
  88. * Solicitar Reembolso
  89. */
  90. public function onEdit($param)
  91. {
  92. try
  93. {
  94. $obj = new StdClass;
  95. if (isset($param['key']))
  96. {
  97. $key = $param['key'];
  98. //$obj->reembolso_id_viagem = $key;
  99. $obj->id_viagem = $key;
  100. //$this->form->setData($obj);
  101. TForm::sendData('formReembolso', $obj);
  102. }
  103. }
  104. catch (Exception $e)
  105. {
  106. new TMessage('error', '<b>Error:</b> ' . $e->getMessage());
  107. }
  108. }
  109. }
  110. ?>


Obrigado.

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (4)


NR

 
  1. <?php
  2. $row_id=$table->addRow();
  3. $lbl = new TLabel('Id Viagem');
  4. $row_id->addCell($lbl);
  5. $row_id->addCell($id_viagem);
  6. // add a row for one field
  7. $row=$table->addRow();
  8. $cell = $row->addCell( $multifield );
  9. $cell->style = "padding-left: 12px";
  10. $cell->colspan = '2';
  11. ?>


Lembre que quando trabalhamos com tabelas em html as colunas de diferentes linhas sempre ficam com o mesmo tamanho, que no caso é o tamanho da maior coluna.
O colspan deve resolver.
FW

Nataniel,

Entendi.
Alterei conforme você sugeriu, mas não adiantou muito.
O TEntry ficou em cima da label valor aproximadamente.
NR

Você pode definir o tamanho das colunas:
 
  1. <?php
  2. $row_id->addCell($lbl)->style = 'width:20%';
  3. $row_id->addCell($id_viagem);
  4. ?>
FW

Nataniel.

Perfeito. Entendi como funciona.
Consegui ajeitar.

Obrigado pela ajuda novamente.