When creating my first homebrew Joomla component, things were working pretty fine ... until now. I would like to create a form which lets the user enter some data. After clicking submit, the data is saved in the model. Immediately after that, the just now entered data should be shown in another layout. (Later, I want to use the values to populate a PDF file, but for now I just would like to show the values entered in the form).
I have a local variable $data
in my controller which is populated using the save()
method of the model as soon as the user clicks the submit button of the form.
This part is working very well. The variable $data
is written to and a var_dump
shows that all the values are correctly written.
My form action
is showing the same view, but with another layout.
When the model is called again, that same local variable, I just wrote to seconds ago is now empty.
I guess that the new call creates a completely new instance of the model whose $data
variable has not yet been initialized.
I know, I could work around this issue if I wrote my data into the database. But I do not need them for later use. I'm quite sure there must be another approach to temporarily save the data until next page request.
In "standard" PHP I would use a session. Maybe a similar construct also exists in Joomla?
But I'm stuck now and I think I do not see the trees for the forest.
(Or can/should/may I use the $_SESSION
super-global variables also within Joomla. But I guess Joomla has their own mechanism, right?)
Can anyone give me a hint please, or show the corresponding easy-to-find example which I did not find yet?
Best Tom