CRM-16019 - Add crmDatepicker binding to CRM_Core_Form
authorColeman Watts <coleman@civicrm.org>
Sun, 20 Dec 2015 22:53:15 +0000 (17:53 -0500)
committerColeman Watts <coleman@civicrm.org>
Mon, 21 Dec 2015 15:55:28 +0000 (10:55 -0500)
CRM/Core/Form.php
js/Common.js

index 8b128ae24a10938dfaa39df5be144f6857c9b646..57619a4ce1e82d2f58243a6346ff2f4885f2d4b8 100644 (file)
@@ -331,6 +331,11 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
       $attributes['class'] .= ' crm-form-wysiwyg';
       $type = "textarea";
     }
+    if ($type == 'datepicker') {
+      $attributes = ($attributes ? $attributes : array()) + array('class' => '');
+      $attributes['data-crm-datepicker'] = json_encode((array) $extra);
+      $type = "text";
+    }
     if ($type == 'select' && is_array($extra)) {
       // Normalize this property
       if (!empty($extra['multiple'])) {
index fda5c0bfda295aa3f1487f187a77159346b61a1a..6a3577806376ead3c5cdda2e3e927d6f82e56625 100644 (file)
@@ -925,6 +925,9 @@ if (!CRM.vars) CRM.vars = {};
       $('.crm-select2:not(.select2-offscreen, .select2-container)', e.target).crmSelect2();
       $('.crm-form-entityref:not(.select2-offscreen, .select2-container)', e.target).crmEntityRef();
       $('select.crm-chain-select-control', e.target).off('.chainSelect').on('change.chainSelect', chainSelect);
+      $('.crm-form-text[data-crm-datepicker]', e.target).each(function() {
+        $(this).crmDatepicker($(this).data('crmDatepicker'));
+      });
       // Cache Form Input initial values
       $('form[data-warn-changes] :input', e.target).each(function() {
         $(this).data('crm-initial-value', $(this).is(':checkbox, :radio') ? $(this).prop('checked') : $(this).val());