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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

"Tip a friend" form.

Go to End

5 Posts   2716 Views


Community Member, 6 Posts

5 November 2008 at 1:49am

Have anyone made "tip a friend" form?

The problem is how to send page link or something else to an email adress that comes from a form that user has been filled out on a website - and automatically send the link to that pages the form are on - to the email adress owners email account?

Any tip?

Have a beautyful day :-)

Martin Pales

Community Member, 19 Posts

18 November 2008 at 5:54am

I am about to work on the same feature. My first idea is to use a custom form validation. I appreciate any help though.


Community Member, 400 Posts

18 November 2008 at 6:48am

You an do this by creating a custom pagetype,

Just create a new page type, then add the form to that (you can do all the validations there), then on the controller make use of the Email class to send emails,

Use this as a reference


Community Member, 6 Posts

19 November 2008 at 4:22am

Edited: 19/11/2008 10:34am

Hello fra Norway!

Here is a code for page.php, but the variable/method for catching the pages URL is missing.

Any tip?

The vairable "$TipFriendFrom" must be in the l .ss file where the form shall be placed. I could'nt see anything in the api link over to help us there.

Here is the page.php code:


class Page extends SiteTree {
static $db = array(
static $has_one = array(

function TipFriendForm() {
$fields = new FieldSet(
new TextField(
$name = "Name",
$title = "Ditt navn: "
new EmailField("Email", "E-post adresse: "),
new HiddenField("Side", $db->URL)
$validator = new RequiredFields("Email");
$actions = new FieldSet(new FormAction("tipFriend", "Send tips"));
return new Form($this, "TipFriendForm", $fields, $actions, $validator);

class Page_Controller extends ContentController {
function init() {


function tipFriend ($data, $form) {

$from = "";
$subject = "Tips fra din venn";
$to = $data["Email"];
$body = $data["Name"] . " har sendt deg følgende link tips: \n" . $data["Side"];

$email = new Email($from, $to, $subject, $body);





Community Member, 23 Posts

20 November 2008 at 1:05am

You could also take a look at the Sharethis module I've used it to great effect in my attempts to make the option to send a message to a friend through e-mail or facebook