Understanding State
Note that when you clicked on the button, the form actually posted back to itself. However,
the state of the form was remembered from one webpage view to the next. This is known as
FormState.
QForm objects, in fact, are stateful objects that maintain its state from one post to the next.
In this example, we have an
$intCounter defined in the form. And basically, whenever
you click on the button, we will increment
$intCounter by one. Note that the HTML template
file is displaying
$intCounter directly via a standard PHP
print statement.
Also note that session variables, cookies, etc. are
not being used here -- only
FormState. In fact,
you can get an idea if you do
View Source... in your browser of the HTML on this page.
You will see a bunch of cryptic letters and numbers for the
Qform__FormState hidden variable.
Those letters and numbers actually represent the serialized version of this
QForm object.