Webylon 3.1 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • EditableCheckbox
  • EditableCheckboxGroupField
  • EditableCountryDropdownField
  • EditableDateField
  • EditableDropdown
  • EditableEmailField
  • EditableFileField
  • EditableFormField
  • EditableFormHeading
  • EditableHiddenField
  • EditableLiteralField
  • EditableMemberListField
  • EditableMultipleOptionField
  • EditableOption
  • EditableRadioField
  • EditableSiteAgreementField
  • EditableTextField
  • FieldEditor
  • SubmittedFileField
  • SubmittedForm
  • SubmittedFormField
  • SubmittedFormReportField
  • UserDefinedForm
  • UserDefinedForm_EmailRecipient
  • UserDefinedForm_SubmittedFormEmail
  • UserFormsVersionedTask
 1 <?php
 2 /**
 3  * EditableDateField
 4  *
 5  * Allows a user to add a date field.
 6  *
 7  * @package userforms
 8  */
 9 
10 class EditableDateField extends EditableFormField {
11     
12     static $singular_name = 'Date Field';
13     
14     static $plural_name = 'Date Fields';
15     
16     function getFieldConfiguration() {
17         $default = ($this->getSetting('DefaultToToday')) ? $this->getSetting('DefaultToToday') : false;
18         $label = _t('EditableFormField.DEFAULTTOTODAY', 'Default to Today?');
19         
20         return new FieldSet(
21             new CheckboxField($this->getSettingName("DefaultToToday"), $label, $default)
22         );
23     }
24     
25     function populateFromPostData($data) {
26         $fieldPrefix = 'Default-';
27         
28         if(empty($data['Default']) && !empty($data[$fieldPrefix.'Year']) && !empty($data[$fieldPrefix.'Month']) && !empty($data[$fieldPrefix.'Day'])) {
29             $data['Default'] = $data['Year'] . '-' . $data['Month'] . '-' . $data['Day'];       
30         }
31         
32         parent::populateFromPostData($data);
33     }
34     
35     /**
36      * Return the form field.
37      *
38      * @todo Make a jQuery safe form field. The current CalendarDropDown
39      *          breaks on the front end.
40      */
41     public function getFormField() {
42         // scripts for jquery date picker
43         Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.core.js');
44         Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.datepicker.js');
45         Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/i18n/jquery-ui-i18n.js'); 
46         Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/i18n/jquery.ui.datepicker-'.i18n::get_lang_from_locale(i18n::get_locale()).'.js');
47         
48         $dateFormat = DateField_View_JQuery::convert_iso_to_jquery_format(i18n::get_date_format());
49 
50         Requirements::customScript(<<<JS
51             (function($) {
52                 $(document).ready(function() {
53                     $('input[name^=EditableDateField]').attr('autocomplete', 'off').datepicker({ dateFormat: '$dateFormat' });
54                 });
55             })(jQuery);
56 JS
57 , 'UserFormsDate');
58 
59         // css for jquery date picker
60         Requirements::css(THIRDPARTY_DIR .'/jquery-ui-themes/smoothness/jquery-ui-1.8rc3.custom.css');
61         
62         $default = ($this->getSetting('DefaultToToday')) ? date('d/m/Y') : $this->Default;
63         
64         return new DateField( $this->Name, $this->Title, $default);
65     }
66     
67     /**
68      * Return the validation information related to this field. This is 
69      * interrupted as a JSON object for validate plugin and used in the 
70      * PHP. 
71      *
72      * @see http://docs.jquery.com/Plugins/Validation/Methods
73      * @return Array
74      */
75     public function getValidation() {
76         return array_merge(
77             parent::getValidation(),
78              array(
79                 'date' => true
80             )
81         );
82     }
83 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.1 API Docs API documentation generated by ApiGen 2.8.0