Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

how can i deal with the $_post parameters before write


Go to End


6 Posts   2522 Views

Avatar
kk

Community Member, 9 Posts

23 June 2008 at 3:28pm

when i create or update a page.

it there any function like onbeforexxxx and how can i get those parameters
directly get from $_POST or $_GET ???

Avatar
Double-A-Ron

Community Member, 607 Posts

23 June 2008 at 4:39pm

I don't know if my method is correct or not, but I add functions for this in the page_controller class for the page I am viewing.

For example, I have a page type called Tour. I have a dropdown box for changing currencies on a page, and this simply refreshes the current page with ?cur=value on the URL. So in my Tour_Controller class, I simple add an init() method at the top (so it is called first when the page loads) and do something like this:


function init() {
    $parent::init();
    
    if($_GET['cur']) {
      // Do my stuff with $_GET['cur'] here
    }
}

Cheers
Aaron

Avatar
Double-A-Ron

Community Member, 607 Posts

23 June 2008 at 4:42pm

Oops, sorry mate - re-read your post and it seems you're talking about the CMS side of things. I have no idea on this sorry, and my post above won't be much good to you.

Aaron

Avatar
kk

Community Member, 9 Posts

23 June 2008 at 4:57pm

yes, the cms admin side. still thanks a lot.
my situation is i create a TestPage and add a new column , testvalue for eg.
and add it to the cms admin panel,where i can input the value

but on the serverside before save the value to the database , i want to change the testvalue.
do some validation or do some text2html things.

Avatar
Willr

Forum Moderator, 5523 Posts

23 June 2008 at 6:24pm

Avatar
kk

Community Member, 9 Posts

23 June 2008 at 7:31pm

another problem is how can i get the request parameter.
the name of the input is not the column of the db,so there is no getter and setter.
can you tell me when the program do getter and setter for the datamodel, where is the code?
i spent much time still can not found