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

_GET variables and basic actions


Go to End


3 Posts   2916 Views

Avatar
Nicolaas

Forum Moderator, 224 Posts

18 October 2007 at 12:49am

Hi Folk

I would like to present my user with a list of items and the option to delete one of them. I can make the list with <a href="myurl/?delete=ID">delete this one</a>. However, how do I setup a function that recognises the get variable so that the item can be deleted.

After that, should I do something like Director::loadSelf()?

What is best practice for dealing with Get variables (as described above)?

Also, is there some built-in Ajax functionality that I could use? OPTIONAL EXTRA :-)

Thanks a million

Nicolaas

Avatar
Ingo

Forum Moderator, 801 Posts

18 October 2007 at 8:48am

there are formfields which provide a UI for listing/deleting subclasses of DataObject or Page (with ajax-goodness, pagination, ...):
http://doc.silverstripe.com/doku.php?id=tablelistfield

> What is best practice for dealing with Get variables (as described above)?
Controller→requestParams - please make sure you properly escape GET/POST (http://doc.silverstripe.com/doku.php?id=secure-development)

alternatively, you can use "urlParams" for this: Director::urlParams(), Controller→urlParams
by default, each url is built like this: controller/action/ID/OtherID
(where each of the parts is an associative index in the urlParams-array)

Avatar
Nicolaas

Forum Moderator, 224 Posts

20 October 2007 at 1:20pm

Thanks Ingo!