Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ContactWidget extends Widget
- {
- private static $db = array(
- 'To' => 'Varchar(255)',
- 'IntroText' => 'Text',
- 'SuccessMessage' => 'Text'
- );
- public function Title()
- {
- return $this->WidgetTitle ? $this->WidgetTitle : _t('ContactWidget.TITLE', 'ContactWidget Title');
- }
- public function CMSTitle()
- {
- return _t('ContactWidget.CMSTITLE', 'ContactWidget CMS Title');
- }
- public function Description()
- {
- return _t('ContactWidget.DESCRIPTION', 'ContactWidget Description');
- }
- public function populateDefaults()
- {
- return array(
- "ButtonText" => _t('Send')
- );
- }
- public function getCMSFields()
- {
- return new FieldList(
- new TextField('To', _t('ContactWidget.TO', 'To')),
- new TextareaField('IntroText', _t('ContactWidget.INTROTEXT', 'Intro text')),
- new TextareaField('SuccessMessage', _t('ContactWidget.SUCCESSES', 'Success message'))
- );
- }
- }
- class ContactWidget_Controller extends WidgetController
- {
- function ContactForm()
- {
- return new Form(
- $this,
- 'ContactForm',
- new FieldList(
- TextField::create('FirstName'),
- EmailField::create('Email')->setAttribute('type', 'email')->setAttribute('placeholder', 'E-mail address')
- ),
- new FieldList(
- FormAction::create('doContactForm')->setTitle(_t('Send'))
- ),
- new RequiredFields(
- 'FirstName',
- 'Email'
- )
- );
- }
- function doContactForm($data)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement