From 23963e2a47b0d98386703d2f91915726e43f07db Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 11 Aug 2014 11:09:31 +1200 Subject: [PATCH] FIX: disable jquery.validation with date fields Inconsistent with date locale formats. --- code/model/formfields/EditableDateField.php | 27 +++++++++------------ templates/ValidationScript.ss | 8 ++++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/code/model/formfields/EditableDateField.php b/code/model/formfields/EditableDateField.php index e9adaa0..f381392 100755 --- a/code/model/formfields/EditableDateField.php +++ b/code/model/formfields/EditableDateField.php @@ -38,22 +38,19 @@ class EditableDateField extends EditableFormField { */ public function getFormField() { $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); + 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"; + } +} \ No newline at end of file diff --git a/templates/ValidationScript.ss b/templates/ValidationScript.ss index 3a0069b..2b5850d 100644 --- a/templates/ValidationScript.ss +++ b/templates/ValidationScript.ss @@ -5,6 +5,14 @@ '{$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({ ignore: ':hidden', errorClass: "required",