Advertisement
Guest User

Untitled

a guest
Oct 19th, 2013
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. <?php
  2.  
  3. class ContactWidget extends Widget
  4. {
  5.     private static $db = array(
  6.         'To' => 'Varchar(255)',
  7.         'IntroText' => 'Text',
  8.         'SuccessMessage' => 'Text'
  9.     );
  10.  
  11.     public function Title()
  12.     {
  13.         return $this->WidgetTitle ? $this->WidgetTitle : _t('ContactWidget.TITLE', 'ContactWidget Title');
  14.     }
  15.  
  16.     public function CMSTitle()
  17.     {
  18.         return _t('ContactWidget.CMSTITLE', 'ContactWidget CMS Title');
  19.     }
  20.  
  21.     public function Description()
  22.     {
  23.         return _t('ContactWidget.DESCRIPTION', 'ContactWidget Description');
  24.     }
  25.  
  26.     public function populateDefaults()
  27.     {
  28.         return array(
  29.             "ButtonText" => _t('Send')
  30.         );
  31.     }
  32.  
  33.     public function getCMSFields()
  34.     {
  35.         return new FieldList(
  36.             new TextField('To', _t('ContactWidget.TO', 'To')),
  37.             new TextareaField('IntroText', _t('ContactWidget.INTROTEXT', 'Intro text')),
  38.             new TextareaField('SuccessMessage', _t('ContactWidget.SUCCESSES', 'Success message'))
  39.         );
  40.     }
  41. }
  42.  
  43. class ContactWidget_Controller extends WidgetController
  44. {
  45.     function ContactForm()
  46.     {
  47.         return new Form(
  48.             $this,
  49.             'ContactForm',
  50.             new FieldList(
  51.                 TextField::create('FirstName'),
  52.                 EmailField::create('Email')->setAttribute('type', 'email')->setAttribute('placeholder', 'E-mail address')
  53.             ),
  54.             new FieldList(
  55.                 FormAction::create('doContactForm')->setTitle(_t('Send'))
  56.             ),
  57.             new RequiredFields(
  58.                 'FirstName',
  59.                 'Email'
  60.             )
  61.         );
  62.     }
  63.  
  64.     function doContactForm($data)
  65.     {
  66.  
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement