From 0b77ccc218baf2620c1ee3ac974fd0d51e68348c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 20 Oct 2016 12:00:37 -0400 Subject: [PATCH] CRM-17869 - Revert custom field date search refactoring to support relative dates --- CRM/Contact/Form/Search/Criteria.php | 7 ++++++- templates/CRM/Custom/Form/Search.tpl | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index a21dc8c037..639814e63a 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -532,7 +532,12 @@ class CRM_Contact_Form_Search_Criteria { foreach ($group['fields'] as $field) { $fieldId = $field['id']; $elementName = 'custom_' . $fieldId; - CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, TRUE); + if ($field['data_type'] == 'Date' && $field['is_search_range']) { + CRM_Core_Form_Date::buildDateRange($form, $elementName, 1, '_from', '_to', ts('From:'), FALSE); + } + else { + CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, TRUE); + } } } } diff --git a/templates/CRM/Custom/Form/Search.tpl b/templates/CRM/Custom/Form/Search.tpl index 85d06e5359..88ea7fc800 100644 --- a/templates/CRM/Custom/Form/Search.tpl +++ b/templates/CRM/Custom/Form/Search.tpl @@ -40,9 +40,14 @@ {assign var="element_name_from" value=$element_name|cat:"_from"} {assign var="element_name_to" value=$element_name|cat:"_to"} + {if $element.data_type neq 'Date'} {$form.$element_name_from.label} {$form.$element_name_from.html|crmAddClass:six}   {$form.$element_name_to.label}  {$form.$element_name_to.html|crmAddClass:six} + {elseif $element.skip_calendar NEQ true } + + {include file="CRM/Core/DateRange.tpl" fieldName=$element_name from='_from' to='_to'} + {/if} {else} {$form.$element_name.label} {$form.$element_name.html} -- 2.25.1