Skip to content

Commit

Permalink
CRM-17869 - Revert custom field date search refactoring to support re…
Browse files Browse the repository at this point in the history
…lative dates
  • Loading branch information
colemanw committed Oct 20, 2016
1 parent 28fd6a3 commit 43aafe3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CRM/Contact/Form/Search/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,12 @@ public static function custom(&$form) {
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);
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions templates/CRM/Custom/Form/Search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@
{assign var="element_name_from" value=$element_name|cat:"_from"}
{assign var="element_name_to" value=$element_name|cat:"_to"}
<tr>
{if $element.data_type neq 'Date'}
<td class="label">{$form.$element_name_from.label}</td><td>
{$form.$element_name_from.html|crmAddClass:six}
&nbsp;&nbsp;{$form.$element_name_to.label}&nbsp;&nbsp;{$form.$element_name_to.html|crmAddClass:six}
{elseif $element.skip_calendar NEQ true }
<td class="label"><label for='{$element_name}'>{$element.label}</label>
{include file="CRM/Core/DateRange.tpl" fieldName=$element_name from='_from' to='_to'}</td><td>
{/if}
{else}
<td class="label">{$form.$element_name.label}</td><td>
{$form.$element_name.html}
Expand Down

0 comments on commit 43aafe3

Please sign in to comment.