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.

Archive /

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

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

how can i deal with the $_post parameters before write


Reply


6 Posts   2162 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, 604 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, 604 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, 5513 Posts

23 June 2008 at 6:24pm

can you use onBeforeWrite() on your dataobject
http://doc.silverstripe.com/doku.php?id=datamodel&s=onbeforewrite#onbeforewrite

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