1: <?php
2: require_once('../qcubed.inc.php');
3:
4: if (!isset($this)) {
5:
6:
7: class ExampleSingleForm extends QForm {
8:
9:
10: protected $lblMessage;
11: protected $btnButton;
12:
13:
14: protected function Form_Create() {
15:
16: $this->lblMessage = new QLabel($this);
17: $this->lblMessage->Text = 'Click the button to change my message.';
18:
19:
20: $this->btnButton = new QButton($this);
21: $this->btnButton->Text = 'Click Me!';
22:
23:
24:
25: $this->btnButton->AddAction(new QClickEvent(), new QAjaxAction('btnButton_Click'));
26: }
27:
28:
29: protected function btnButton_Click($strFormId, $strControlId, $strParameter) {
30: $this->lblMessage->Text = 'Hello, world!';
31: }
32:
33: }
34:
35:
36:
37:
38:
39:
40: ExampleSingleForm::Run('ExampleSingleForm', __FILE__);
41: return;
42: }
43:
44:
45: ?>
46:
47: <?php require('../includes/header.inc.php'); ?>
48: <?php $this->RenderBegin(); ?>
49:
50: <div id="instructions">
51: <h1>Hello World, Revisited... Again... Again</h1>
52:
53: <p>We use the AJAX-enabled "Hello World" example to explain how you can make single file <strong>QForm</strong> pages.
54: Note that this approach is <em>not always recommended</em> -- keeping the display logic (.php) file separate
55: from the presentation HTML template (.tpl.php) file helps to enforce the good design and separation of display
56: logic from the presentation layer (e.g. keeping the V and C separate in MVC).</p>
57:
58: <p>However, there may be times when you want a simpler architecture of single-file forms, or you
59: are making some very simple <strong>QForm</strong> pages and you do not want to deal with the overhead
60: of the dual-file format. This example shows how you can use built-in PHP functionality to code your
61: <strong>QForm</strong> as a single .php file.</p>
62:
63: <p>Feel free to <strong>View Source</strong> (the button below) to see how this is done.</p>
64: </div>
65:
66: <div id="demoZone">
67: <p><?php $this->lblMessage->Render(); ?></p>
68: <p><?php $this->btnButton->Render(); ?></p>
69: </div>
70:
71: <?php $this->RenderEnd(); ?>
72: <?php require('../includes/footer.inc.php'); ?>