Problems with array() in $params in backend module

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
NaN

Problems with array() in $params in backend module

Post by NaN »

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

Code: Select all


[pref_name] => Array
        (
            [0] => first item
            [1] => second item
            [2] => third item
            ...
        )

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

Code: Select all


[pref_name] => 

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.
Last edited by NaN on Thu Sep 25, 2008 12:53 am, edited 1 time in total.
NaN

Re: Problems with array() in $params in backend module

Post by NaN »

May i point someones attention to that topic again?
I could change some files to get it the way i want to but is there any reason why CMSms acts like that?
I don't like to modify core files whenever things don't work like i expect. (excepting errors ofcourse)
User avatar
aln_cms
Forum Members
Forum Members
Posts: 88
Joined: Mon Jan 08, 2007 7:09 pm
Location: Ireland

Re: Problems with array() in $params in backend module

Post by aln_cms »

Hi,

I only took a quick look at this so I may be well off the mark here - if you are re-directing to another page, then the problem may be that the prefs are not getting POSTed to the target script?

Alan
--
Alan Ryan
Lead Developer
CodeCrunchers Internet Software Development - Ireland
http://www.codecrunchers.ie
yabune
Forum Members
Forum Members
Posts: 40
Joined: Wed Dec 05, 2007 7:28 pm

Re: Problems with array() in $params in backend module

Post by yabune »

Hi,

I'm having a similar problem...

I also have a backend panel with two tabs.

With one tab I'm being able to post the vars to the following page, but in the second tab the vars aren't posted...
But the code is similar...

But I have this working before... I think it starts happening after upgrading to version 1.4.1 but I'm not sure...
yabune
Forum Members
Forum Members
Posts: 40
Joined: Wed Dec 05, 2007 7:28 pm

Re: Problems with array() in $params in backend module

Post by yabune »

I solved my problem.

My problem was that I was using the reserver name $id to another variable.

Maybe this helps: http://forum.cmsmadesimple.org/index.php/topic,26364.0.html
Post Reply

Return to “Developers Discussion”