FIX: disable jquery.validation with date fields

Inconsistent with date locale formats.
This commit is contained in:
Will Rossiter 2014-08-11 11:09:31 +12:00
parent c3386b48b2
commit 23963e2a47
2 changed files with 20 additions and 15 deletions

View File

@ -38,22 +38,19 @@ class EditableDateField extends EditableFormField {
*/ */
public function getFormField() { public function getFormField() {
$defaultValue = ($this->getSetting('DefaultToToday')) ? date('Y-m-d') : $this->Default; $defaultValue = ($this->getSetting('DefaultToToday')) ? date('Y-m-d') : $this->Default;
$field = new DateField( $this->Name, $this->Title, $defaultValue); $field = new EditableDateField_FormField( $this->Name, $this->Title, $defaultValue);
$field->setConfig('showcalendar', true); $field->setConfig('showcalendar', true);
return $field; return $field;
} }
/**
* Return the validation information related to this field. This is
* interrupted as a JSON object for validate plugin and used in the
* PHP.
*
* @see http://docs.jquery.com/Plugins/Validation/Methods
* @return Array
*/
public function getValidation() {
return array_merge(parent::getValidation(), array(
'date' => true
));
}
} }
/**
* @package userforms
*/
class EditableDateField_FormField extends DateField {
public function Type() {
return "date-alt text";
}
}

View File

@ -5,6 +5,14 @@
'{$Name.JS}': '{$ErrorMessage.JS}'<% if not Last %>,<% end_if %><% end_if %><% end_if %><% end_loop %> '{$Name.JS}': '{$ErrorMessage.JS}'<% if not Last %>,<% end_if %><% end_if %><% end_if %><% end_loop %>
}; };
$(document).on("click", "input.text[data-showcalendar]", function() {
$(this).ssDatepicker();
if($(this).data('datepicker')) {
$(this).datepicker('show');
}
});
$("#Form_Form").validate({ $("#Form_Form").validate({
ignore: ':hidden', ignore: ':hidden',
errorClass: "required", errorClass: "required",