Problems with array() in $params in backend module
Posted: Wed Sep 03, 2008 11:46 pm
Hello,
i have a problem developing a module.
My english is not the best one so this will be a bit difficult to explain...
Example:
I have a backend panel with two tabs.
On tab contains a general list of the modules content items.
The 2nd tab contains some preferences that can be setup by the user.
When submitting the preferences the action "savePrefs" will be executed (action.savePrefs.php).
After storing the settings into the database i redirect to the action "defaultadmin" (action.defaultadmin.php) to return to the default modules admin panel with a message "Preferences saved".
I recognized that the breadcrumbs below the main menu disapears when the preferences are submitted.
I noticed that this is because i was using the function $this->DoAction('defaultadmin', $id, $params, $returnid); to return to the default modules admin panel.
When looking into some other modules source code i realized that there is another function $this->Redirect($id, 'defaultadmin', $returnid, $params);.
So i tried this one and the breadcrumbs stayed there where they should be.
In the prferences tab of my module there is a multiple select list wich i create with the CMSms API function $this->CreateInputSelectList($id, 'pref_name[]', $prefs, $selected_prefs,count($prefs),'',true));
In the preferences tab is also a calendar where you can browse through the months and select some days that can be stored into the database when submitting the preferences form.
When browsing through the months the preferences form will be submitted to the action "savePrefs" but nothing is stored since the button the user used is named "next" and my "savePrefs" action is awaiting a param named "submit" wich is only submitted when clicked a button called "submit". So the user is redirected to the action "defaultadmin" without any changes.
The "defaultadmin" action checks for the param "next" (or "prev") to calculate the shown month.
It also checks for some other params of the preferences form so that the preferences will only be loaded from the database if the modules admin panel is loaded the first time. I do that to gain some more performance when browsing trough the months.
The problem is that the selected prefs of the multiple select list i mentioned above disapear when redirecting from "savePrefs" to "defaultadmin".
That means when using print_r($params); in the "savePrefs" action the output is
So it is an array.
After redirecting with the funtion $this->Redirect(); the output of the params from the "defaultadmin" (also using print_r($params); ) is
So what's going on?
What hapened to the array?
When using the function $this->DoAction(); the array in the params will be okay but the breadcrumbs disapears.
Anyone with the same problems?
Any suggestions?
Thanks in advance.
i have a problem developing a module.
My english is not the best one so this will be a bit difficult to explain...
Example:
I have a backend panel with two tabs.
On tab contains a general list of the modules content items.
The 2nd tab contains some preferences that can be setup by the user.
When submitting the preferences the action "savePrefs" will be executed (action.savePrefs.php).
After storing the settings into the database i redirect to the action "defaultadmin" (action.defaultadmin.php) to return to the default modules admin panel with a message "Preferences saved".
I recognized that the breadcrumbs below the main menu disapears when the preferences are submitted.

I noticed that this is because i was using the function $this->DoAction('defaultadmin', $id, $params, $returnid); to return to the default modules admin panel.
When looking into some other modules source code i realized that there is another function $this->Redirect($id, 'defaultadmin', $returnid, $params);.
So i tried this one and the breadcrumbs stayed there where they should be.

In the prferences tab of my module there is a multiple select list wich i create with the CMSms API function $this->CreateInputSelectList($id, 'pref_name[]', $prefs, $selected_prefs,count($prefs),'',true));
In the preferences tab is also a calendar where you can browse through the months and select some days that can be stored into the database when submitting the preferences form.
When browsing through the months the preferences form will be submitted to the action "savePrefs" but nothing is stored since the button the user used is named "next" and my "savePrefs" action is awaiting a param named "submit" wich is only submitted when clicked a button called "submit". So the user is redirected to the action "defaultadmin" without any changes.
The "defaultadmin" action checks for the param "next" (or "prev") to calculate the shown month.
It also checks for some other params of the preferences form so that the preferences will only be loaded from the database if the modules admin panel is loaded the first time. I do that to gain some more performance when browsing trough the months.
The problem is that the selected prefs of the multiple select list i mentioned above disapear when redirecting from "savePrefs" to "defaultadmin".
That means when using print_r($params); in the "savePrefs" action the output is
Code: Select all
[pref_name] => Array
(
[0] => first item
[1] => second item
[2] => third item
...
)
After redirecting with the funtion $this->Redirect(); the output of the params from the "defaultadmin" (also using print_r($params); ) is
Code: Select all
[pref_name] =>
What hapened to the array?
When using the function $this->DoAction(); the array in the params will be okay but the breadcrumbs disapears.
Anyone with the same problems?
Any suggestions?
Thanks in advance.