Fixed set default for date fields
This commit is contained in:
parent
c9aa4e0955
commit
d975405623
@ -82,13 +82,16 @@ class CRM_EntityTemplates_Utils {
|
|||||||
if ($form->_entityTemplateId) {
|
if ($form->_entityTemplateId) {
|
||||||
$formValues = CRM_EntityTemplates_BAO_EntityTemplates::getFormValues($form->_entityTemplateId);
|
$formValues = CRM_EntityTemplates_BAO_EntityTemplates::getFormValues($form->_entityTemplateId);
|
||||||
$formValues['entity_template_id'] = $form->_entityTemplateId;
|
$formValues['entity_template_id'] = $form->_entityTemplateId;
|
||||||
|
|
||||||
|
self::formatDateParams($formValues, $form->_elements);
|
||||||
$form->setDefaults($formValues);
|
$form->setDefaults($formValues);
|
||||||
|
|
||||||
CRM_Core_Resources::singleton()->addScript("
|
CRM_Core_Resources::singleton()->addScript("
|
||||||
CRM.$(function($) {
|
CRM.$(function($) {
|
||||||
$(document).ajaxSend(function(event, jqxhr, settings) {
|
$(document).ajaxSend(function(event, jqxhr, settings) {
|
||||||
if (settings.url .indexOf('civicrm/custom') != -1) {
|
if (settings.url .indexOf('civicrm/custom') != -1) {
|
||||||
settings.url = settings.url + '&templateId={$form->_entityTemplateId}';
|
settings.url = settings.url + '&templateId={$form->_entityTemplateId}';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})",
|
})",
|
||||||
10,
|
10,
|
||||||
@ -143,4 +146,24 @@ class CRM_EntityTemplates_Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format Date field values in params.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @param object $elements
|
||||||
|
*/
|
||||||
|
public static function formatDateParams(&$params, $elements) {
|
||||||
|
foreach ($elements as $element) {
|
||||||
|
if (!empty($element->_attributes) && array_key_exists(
|
||||||
|
'data-crm-datepicker',
|
||||||
|
$element->_attributes
|
||||||
|
)) {
|
||||||
|
$name = $element->_attributes['name'];
|
||||||
|
if (!CRM_Utils_System::isNull($params[$name])) {
|
||||||
|
$params[$name] = date('Y-m-d H:i:s', strtotime($params[$name]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user