1: <?php
2: require_once('../qcubed.inc.php');
3:
4: class BasicForm extends QForm {
5: protected $txtText;
6: protected $txtText2;
7: protected $lstSelect;
8: protected $lstSelect2;
9: protected $lstCheck;
10: protected $lstCheck2;
11: protected $lstRadio;
12: protected $chkCheck;
13: protected $rdoRadio1;
14: protected $rdoRadio2;
15: protected $rdoRadio3;
16:
17:
18: protected $btnImage;
19:
20: protected $btnServer;
21: protected $btnAjax;
22: protected $btnSetItemsAjax;
23:
24: protected function Form_Create() {
25: $this->txtText = new QTextBox($this);
26: $this->txtText->Text = 'Default';
27: $this->txtText->Name = 'TextBox';
28:
29: $this->txtText2 = new QTextBox($this);
30: $this->txtText2->Text = 'Big';
31: $this->txtText2->Name = 'TextBox';
32: $this->txtText2->TextMode = QTextMode::MultiLine;
33: $this->txtText2->Rows = 3;
34:
35: $this->chkCheck = new QCheckBox($this);
36: $this->chkCheck->Name = 'CheckBox';
37: $this->chkCheck->WrapLabel = true;
38:
39: $items = array (1=>'Item1', 2=>'Item2', 3=>'Item3', 4=>'Item4');
40: $this->lstSelect = new QListBox($this);
41: $this->lstSelect->AddItems ($items);
42: $this->lstSelect->Name = 'Select';
43:
44: $this->lstSelect2 = new QListBox($this);
45: $this->lstSelect2->AddItems ($items);
46: $this->lstSelect2->Name = 'Multiselect';
47: $this->lstSelect2->SelectionMode = QSelectionMode::Multiple;
48:
49: $this->lstCheck = new QCheckBoxList($this);
50: $this->lstCheck->AddItems ($items);
51: $this->lstCheck->Name = 'Check List';
52: $this->lstCheck->RepeatDirection = QRepeatDirection::Horizontal;
53: $this->lstCheck->RepeatColumns = 4;
54:
55: $this->lstCheck2 = new QCheckBoxList($this);
56: $this->lstCheck2->AddItems ($items);
57: $this->lstCheck2->Name = 'Check List';
58: $this->lstCheck2->RepeatColumns = 1;
59: $this->lstCheck2->MaxHeight = 100;
60: $this->lstCheck2->WrapLabel = true;
61: $this->lstCheck2->Name = 'Check List 2';
62:
63: $this->lstRadio = new QRadioButtonList($this);
64: $this->lstRadio->AddItems ($items);
65: $this->lstRadio->Name = 'Radio List';
66: $this->lstRadio->RepeatDirection = QRepeatDirection::Horizontal;
67: $this->lstRadio->RepeatColumns = 4;
68: $this->lstRadio->SelectedIndex = 1;
69:
70: $this->rdoRadio1 = new QRadioButton($this);
71: $this->rdoRadio1->Name = 'Item 1';
72: $this->rdoRadio1->GroupName = 'MyGroup';
73: $this->rdoRadio2 = new QRadioButton($this);
74: $this->rdoRadio2->Name = 'Item 2';
75: $this->rdoRadio2->GroupName = 'MyGroup';
76: $this->rdoRadio3 = new QRadioButton($this);
77: $this->rdoRadio3->Name = 'Item 3';
78: $this->rdoRadio3->GroupName = 'MyGroup';
79:
80: $this->btnImage = new QImageButton($this);
81: $this->btnImage->Name = 'Image Button';
82: $this->btnImage->ImageUrl = __PHP_ASSETS__ . '/examples/images/data_model_thumbnail.png';
83: $this->btnImage->AddAction (new QClickEvent(), new QRegisterClickPositionAction());
84:
85: $this->btnServer = new QButton ($this);
86: $this->btnServer->Text = 'Server Submit';
87: $this->btnServer->AddAction(new QClickEvent(), new QServerAction('submit_click'));
88:
89: $this->btnAjax = new QButton ($this);
90: $this->btnAjax->Text = 'Ajax Submit';
91: $this->btnAjax->AddAction(new QClickEvent(), new QAjaxAction('submit_click'));
92:
93: $this->btnSetItemsAjax = new QButton ($this);
94: $this->btnSetItemsAjax->Text = 'Ajax Set Items';
95: $this->btnSetItemsAjax->AddAction(new QClickEvent(), new QAjaxAction('setItems_click'));
96:
97: }
98:
99: protected function submit_click($strFormId, $strControlId, $strParameter) {
100: $this->txtText->Warning = 'Value = ' . $this->txtText->Text;
101: $this->txtText2->Warning = 'Value = ' . $this->txtText2->Text;
102:
103: $this->chkCheck->Warning = 'Value = ' . $this->chkCheck->Checked;
104: $this->lstSelect->Warning = 'Value = ' . $this->lstSelect->SelectedValue;
105: $this->lstSelect2->Warning = 'Values = ' . implode (',', $this->lstSelect2->SelectedValues);
106: $this->lstCheck->Warning = 'Values = ' . implode (',', $this->lstCheck->SelectedValues);
107: $this->lstCheck2->Warning = 'Values = ' . implode (',', $this->lstCheck2->SelectedValues);
108: $this->lstRadio->Warning = 'Value = ' . $this->lstRadio->SelectedValue;
109: $this->rdoRadio1->Warning = 'Value = ' . $this->rdoRadio1->Checked;
110: $this->rdoRadio2->Warning = 'Value = ' . $this->rdoRadio2->Checked;
111: $this->rdoRadio3->Warning = 'Value = ' . $this->rdoRadio3->Checked;
112: $this->btnImage->Warning = 'X = ' . $this->btnImage->ClickX . '; Y = ' . $this->btnImage->ClickY;
113: }
114:
115: 116: 117: 118: 119: 120: 121: 122:
123: protected function setItems_click($strFormId, $strControlId, $strParameter) {
124: $this->lstSelect2->SelectedValues = [2,4];
125: $this->lstCheck2->SelectedValues = [1,3];
126: $this->lstRadio->SelectedIndex = 3;
127:
128: $this->chkCheck->Checked = true;
129: $this->rdoRadio2->Checked = true;
130: }
131:
132: }
133:
134: BasicForm::Run('BasicForm');
135: