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:
<?php
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() {
parent::init();
Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");
}
function tipFriend ($data, $form) {
$from = "system@w3spor.no";
$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);
$email->send();
Director::redirectBack();
}
}
?>