コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
 /**
  * Class constructor
  * Creates the page
  */
 function __construct()
 {
     parent::__construct();
     // create the notebook
     $notebook = new TNotebook(620, 410);
     // create the form
     $this->form = new TForm();
     // creates the notebook page
     $table = new TTable();
     // add the notebook inside the form
     $this->form->add($table);
     // adds the notebook page
     $notebook->appendPage('Input elements', $this->form);
     // create the form fields
     $field1 = new TEntry('field1');
     $field2 = new TEntry('field2');
     $field3 = new TEntry('field3');
     $field4 = new TEntry('field4');
     $field5 = new TEntry('field5');
     $field6 = new TPassword('field6');
     $field7 = new TDate('field7');
     $field8 = new TSpinner('field8');
     $field9 = new TSlider('field9');
     $field10 = new TText('field10');
     $field1->setTip('Tip for field 1');
     $field2->setTip('Tip for field 2');
     $field3->setTip('Tip for field 3');
     $field4->setTip('Tip for field 4');
     $field5->setTip('Tip for field 5');
     $field6->setTip('Tip for field 6');
     $field7->setTip('Tip for field 7');
     $field8->setTip('Tip for field 8');
     $field9->setTip('Tip for field 9');
     $field10->setTip('Tip for field 10');
     $field2->setValue('123');
     $field2->setEditable(FALSE);
     $field3->setMask('99.999-999');
     $field4->setMaxLength(10);
     $field5->setCompletion(array('Allen', 'Albert', 'Alberto', 'Alladin'));
     $field7->setSize(100);
     $field8->setRange(0, 100, 10);
     $field9->setRange(0, 100, 10);
     $field8->setValue(30);
     $field9->setValue(50);
     $field10->setSize(300, 80);
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('TEntry object:'));
     $cell = $row->addCell($field1);
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('TEntry not editable:'));
     $cell = $row->addCell($field2);
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('TEntry with mask:'));
     $cell = $row->addCell($field3);
     $cell = $row->addCell(new TLabel('99.999-999'));
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('TEntry with maxlength (10):'));
     $cell = $row->addCell($field4);
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('TEntry with completion (a..):'));
     $cell = $row->addCell($field5);
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('TPassword object:'));
     $cell = $row->addCell($field6);
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('TDate Object:'));
     $cell = $row->addCell($field7);
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('Spinner Object:'));
     $cell = $row->addCell($field8);
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('Slider Object:'));
     $cell = $row->addCell($field9);
     // add a row for one field
     $row = $table->addRow();
     $row->addCell(new TLabel('TText Object:'));
     $cell = $row->addCell($field10);
     // 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');
     // define wich are the form fields
     $this->form->setFields(array($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10, $button1));
     // add a row for the button
     $row = $table->addRow();
     $row->addCell($button1);
     // add the form inside the page
     parent::add($notebook);
 }
コード例 #3
0
 /**
  * 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);
 }