ENHANCEMENT: using sys locale instead user selection

This commit is contained in:
Carlos Barberis 2010-11-15 23:23:11 +00:00
parent e4f7c419b3
commit 9b17399cd4

View File

@ -16,21 +16,11 @@ class EditableDateField extends EditableFormField {
static $plural_name = 'Date Fields'; static $plural_name = 'Date Fields';
protected $dateFormats = array(
'dd/mm/yy' => 'dd/mm/yy',
'dd-mm-yy' => 'dd-mm-yy',
'mm/dd/yy' => 'mm/dd/yy',
'mm-dd-yy' => 'mm-dd-yy',
'MM d, yy' => 'MM d, yy'
);
function getFieldConfiguration() { function getFieldConfiguration() {
$defaultToToday = ($this->getSetting('DefaultToToday')) ? $this->getSetting('DefaultToToday') : false; $defaultToToday = ($this->getSetting('DefaultToToday')) ? $this->getSetting('DefaultToToday') : false;
$defaultDateFormat = ($this->getSetting('DateFormat')) ? $this->getSetting('DateFormat') : 'dd/mm/yy';
$dateFormatConf = new DropdownField("Fields[$this->ID][CustomSettings][DateFormat]", 'Date format', $this->dateFormats, $defaultDateFormat);
return new FieldSet( return new FieldSet(
new CheckboxField("Fields[$this->ID][CustomSettings][DefaultToToday]", _t('EditableFormField.DEFAULTTOTODAY', 'Default to Today?'), $defaultToToday), new CheckboxField("Fields[$this->ID][CustomSettings][DefaultToToday]", _t('EditableFormField.DEFAULTTOTODAY', 'Default to Today?'), $defaultToToday)
$dateFormatConf
); );
} }
@ -55,11 +45,12 @@ class EditableDateField extends EditableFormField {
Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.core.js'); Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.core.js');
Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.datepicker.js'); Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.datepicker.js');
$dateFormat = $this->getSetting('DateFormat'); $dateFormat = DateField_View_JQuery::convert_iso_to_jquery_format(i18n::get_date_format());
Requirements::customScript(<<<JS Requirements::customScript(<<<JS
(function(jQuery) { (function(jQuery) {
$(document).ready(function() { $(document).ready(function() {
$('input[name^=EditableDateField]').attr('autocomplete', 'off').datepicker({dateFormat:'$dateFormat'}); $('input[name^=EditableDateField]').attr('autocomplete', 'off').datepicker({ dateFormat: '$dateFormat' });
}); });
})(jQuery); })(jQuery);
JS JS