Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Defines the HomePage page type
- */
- class HomePage extends Page {
- static $db = array(
- );
- static $has_one = array(
- );
- static $icon = "tutorial/images/treeicons/home";
- function LatestNews($num=5) {
- $news = DataObject::get_one("ArticleHolder");
- return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
- }
- }
- class HomePage_Controller extends Page_Controller {
- function BrowserPollForm() {
- // Create fields
- $fields = new FieldSet(
- new TextField('Name'),
- new OptionsetField('Browser', 'Your Favourite Browser', array(
- 'Firefox' => 'Firefox',
- 'Internet Explorer' => 'Internet Explorer',
- 'Safari' => 'Safari',
- 'Opera' => 'Opera',
- 'Lynx' => 'Lynx'
- ))
- );
- // Create actions
- $actions = new FieldSet(
- new FormAction('doBrowserPoll', 'Submit')
- );
- return new Form($this, 'BrowserPollForm', $fields, $actions);
- // Create validator
- $validator = new RequiredFields('Name', 'Browser');
- return new Form($this, 'BrowserPollForm', $fields, $actions, $validator);
- }
- function doBrowserPoll($data, $form) {
- $submission = new BrowserPollSubmission();
- $form->saveInto($submission);
- $submission->write();
- Director::redirectBack();
- }
- }
- ?>
Add Comment
Please, Sign In to add comment