mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
BUGFIX: EditableDateFields nice calendar does not popup in the frontend
This commit is contained in:
parent
46c0efc9ae
commit
ee3de104ec
@ -33,33 +33,14 @@ class EditableDateField extends EditableFormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the form field.
|
* Return the form field
|
||||||
*
|
*
|
||||||
* @todo Make a jQuery safe form field. The current CalendarDropDown
|
|
||||||
* breaks on the front end.
|
|
||||||
*/
|
*/
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
// scripts for jquery date picker
|
$defaultValue = ($this->getSetting('DefaultToToday')) ? date('Y-m-d') : $this->Default;
|
||||||
Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.core.js');
|
$field = new DateField( $this->Name, $this->Title, $defaultValue);
|
||||||
Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.datepicker.js');
|
$field->setConfig('showcalendar', true);
|
||||||
|
return $field;
|
||||||
$dateFormat = DateField_View_JQuery::convert_iso_to_jquery_format(i18n::get_date_format());
|
|
||||||
|
|
||||||
Requirements::customScript(<<<JS
|
|
||||||
(function(jQuery) {
|
|
||||||
$(document).ready(function() {
|
|
||||||
$('input[name^=EditableDateField]').attr('autocomplete', 'off').datepicker({ dateFormat: '$dateFormat' });
|
|
||||||
});
|
|
||||||
})(jQuery);
|
|
||||||
JS
|
|
||||||
, 'UserFormsDate');
|
|
||||||
|
|
||||||
// css for jquery date picker
|
|
||||||
Requirements::css(THIRDPARTY_DIR .'/jquery-ui-themes/smoothness/jquery-ui-1.8rc3.custom.css');
|
|
||||||
|
|
||||||
$default = ($this->getSetting('DefaultToToday')) ? date('d/m/Y') : $this->Default;
|
|
||||||
|
|
||||||
return new DateField( $this->Name, $this->Title, $default);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user