1: <?php
2: require_once('../qcubed.inc.php');
3: class NestedTabForm extends QForm
4: {
5: 6: 7:
8: protected $tabs;
9: 10: 11:
12: protected $log;
13: 14: 15:
16: protected $panels = [];
17:
18: protected function Form_Create()
19: {
20: $this->log = new QPanel($this);
21: $this->tabs = new QTabs($this);
22: $this->tabs->Headers = ['one', 'two'];
23: $this->panels[] = $this->CreatePanel("hi", $this->tabs);
24: $pnl = new QPanel($this->tabs);
25: $pnl->AutoRenderChildren = true;
26: $this->panels[] = $pnl;
27: $tabs = new QTabs($this->panels[0]);
28: $tabs->Headers = ['three', 'four'];
29: $this->CreatePanel("aaa2", $tabs);
30: $this->CreatePanel("bbb", $tabs);
31: $this->tabs->AddAction(new QTabs_ActivateEvent(), new QAjaxAction('tabs_Load'));
32:
33: }
34:
35: public function CreatePanel($strContent, $objTab)
36: {
37: $pnl = new QPanel($objTab);
38: $pnl->AutoRenderChildren = true;
39: $pnlContent = new QPanel($pnl);
40: $pnlContent->Text = $strContent;
41: return $pnl;
42: }
43:
44: public function tabs_Load($strForm, $strControl, $strParam, $params)
45: {
46: 47: 48:
49: $objControl = $this->GetControl($strControl);
50: if (!$objControl) {
51: return;
52: }
53: $this->log->Text = $objControl->SelectedId . ' activated';
54: if ($objControl->Active == 1) {
55: $pnlParent = $this->GetControl($objControl->SelectedId);
56: if (count($pnlParent->GetChildControls()) > 0) {
57: return;
58: }
59: $pnlContent = new QPanel($this->panels[1]);
60: $pnlContent->Text = "there ";
61: $this->tabs->Refresh();
62: }
63: }
64: }
65: NestedTabForm::Run('NestedTabForm');
66: