foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
- 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, FALSE, TRUE
- );
- }
+ CRM_Core_BAO_CustomField::addQuickFormElement($form,
+ $elementName,
+ $fieldId,
+ FALSE, FALSE, TRUE
+ );
}
}
}
$options = CRM_Utils_Array::value('values', civicrm_api3('contact', 'getoptions', array(
'field' => "custom_$fieldId",
'context' => $search ? 'search' : 'create',
- ), array()));
+ )), array());
// Consolidate widget types to simplify the below switch statement
if ($search || ($widget !== 'AdvMulti-Select' && strpos($widget, 'Select') !== FALSE)) {
break;
case 'Select Date':
+ $attr = array('data-crm-custom' => $dataCrmCustomVal);
+ $params = array(
+ 'date' => $field->date_format,
+ 'minDate' => isset($field->start_date_years) ? (date('Y') - $field->start_date_years) . '-01-01' : NULL,
+ 'maxDate' => isset($field->end_date_years) ? (date('Y') + $field->end_date_years) . '-01-01' : NULL,
+ 'time' => $field->time_format ? $field->time_format * 12 : FALSE,
+ );
if ($field->is_search_range && $search) {
- $qf->addDate($elementName . '_from', $label . ' - ' . ts('From'), FALSE,
- array(
- 'format' => $field->date_format,
- 'timeFormat' => $field->time_format,
- 'startOffset' => $field->start_date_years,
- 'endOffset' => $field->end_date_years,
- 'data-crm-custom' => $dataCrmCustomVal,
- )
- );
-
- $qf->addDate($elementName . '_to', ts('To'), FALSE,
- array(
- 'format' => $field->date_format,
- 'timeFormat' => $field->time_format,
- 'startOffset' => $field->start_date_years,
- 'endOffset' => $field->end_date_years,
- 'data-crm-custom' => $dataCrmCustomVal,
- )
- );
+ $qf->add('datepicker', $elementName . '_from', $label, $attr + array('placeholder' => ts('From')), FALSE, $params);
+ $qf->add('datepicker', $elementName . '_to', NULL, $attr + array('placeholder' => ts('To')), FALSE, $params);
}
else {
- $required = $useRequired && !$search;
-
- $qf->addDate($elementName, $label, $required, array(
- 'format' => $field->date_format,
- 'timeFormat' => $field->time_format,
- 'startOffset' => $field->start_date_years,
- 'endOffset' => $field->end_date_years,
- 'data-crm-custom' => $dataCrmCustomVal,
- ));
+ $qf->add('datepicker', $elementName, $label, $attr, $useRequired && !$search, $params);
}
break;
}
break;
- case 'Select Date':
- if ($value) {
- list($defaults[$elementName], $defaults[$elementName . '_time']) = CRM_Utils_Date::setDateDefaults(
- $value,
- NULL,
- $customField->date_format,
- $customField->time_format
- );
- }
- break;
-
case 'Autocomplete-Select':
if ($customField->data_type == 'ContactReference') {
if (is_numeric($value)) {
}
break;
- case 'Select Date':
- if (isset($value)) {
- if (empty($field['time_format'])) {
- list($defaults[$elementName]) = CRM_Utils_Date::setDateDefaults($value, NULL,
- $field['date_format']
- );
- }
- else {
- $timeElement = $elementName . '_time';
- if (substr($elementName, -1) == ']') {
- $timeElement = substr($elementName, 0, -1) . '_time]';
- }
- list($defaults[$elementName], $defaults[$timeElement]) = CRM_Utils_Date::setDateDefaults($value, NULL, $field['date_format'], $field['time_format']);
- }
- }
- break;
-
case 'Multi-Select Country':
case 'Multi-Select State/Province':
if (isset($value)) {
public static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FALSE, $prefix = '') {
$form->assign_by_ref("{$prefix}groupTree", $groupTree);
- // this is fix for date field
- $form->assign('currentYear', date('Y'));
-
foreach ($groupTree as $id => $group) {
CRM_Core_ShowHideBlocks::links($form, $group['title'], '', '');
foreach ($group['fields'] as $field) {
/**
* Add date.
*
- * @code
- * // if you need time
- * $attributes = array(
- * 'addTime' => true,
- * 'formatType' => 'relative' or 'birth' etc check advanced date settings
- * );
- * @endcode
+ * @deprecated
+ * Use $this->add('datepicker', ...) instead.
*
* @param string $name
* Name of the element.
}
/**
- * Function that will add date and time.
+ * Function that will add date and time.
+ *
+ * @deprecated
+ * Use $this->add('datepicker', ...) instead.
*
* @param string $name
* @param string $label
copyAttributes($dataField, $dateField, ['placeholder', 'style', 'class', 'disabled']);
$dateField.addClass('crm-form-text crm-form-date');
settings.date = typeof settings.date === 'string' ? settings.date : CRM.config.dateInputFormat;
- settings.changeMonth = _.includes('m', settings.date);
- settings.changeYear = _.includes('y', settings.date);
+ settings.changeMonth = _.includes(settings.date, 'm');
+ settings.changeYear = _.includes(settings.date, 'y');
+ settings.minDate = settings.minDate ? CRM.utils.makeDate(settings.minDate) : null;
+ settings.maxDate = settings.maxDate ? CRM.utils.makeDate(settings.maxDate) : null;
$dateField.datepicker(settings).change(updateDataField);
}
// Rudimentary validation. TODO: Roll into use of jQUery validate and ui.datepicker.validation
<tr>
<td class="label">{$form.address.$blockId.$element_name.label}</td>
<td class="html-adjust">
- {if $element.data_type neq 'Date'}
- {$form.address.$blockId.$element_name.html}
- {elseif $element.skip_calendar NEQ true }
- {include file="CRM/common/jcalendar.tpl" blockId=$blockId blockSection='address' elementName=$element_name}
- {/if}
+ {$form.address.$blockId.$element_name.html}
{if $element.data_type eq 'File'}
{if $element.element_value.data}
<tr class="custom_field-row {$element.element_name}-row">
<td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if}</td>
<td class="html-adjust">
- {if $element.data_type neq 'Date' OR ($element.data_type eq 'Date' AND $element.is_view eq 1)}
- {$form.$element_name.html}
- {elseif $element.skip_calendar NEQ true}
- {include file="CRM/common/jcalendar.tpl" elementName=$element_name}
- {/if}
-
+ {$form.$element_name.html}
{if $element.data_type eq 'File'}
{if $element.element_value.data}
<div class="crm-attachment-wrapper crm-entity" id="file_{$element_name}">
<tr>
<td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$form.$element_name.label}{/if}</td>
<td>
- {if $element.data_type neq 'Date'}
- {$form.$element_name.html}
- {elseif $element.skip_calendar NEQ true }
- {include file="CRM/common/jcalendar.tpl" elementName=$element_name}
- {/if}
+ {$form.$element_name.html}
{if $element.html_type eq 'Autocomplete-Select'}
{if $element.data_type eq 'ContactReference'}
{include file="CRM/Custom/Form/ContactReference.tpl"}
{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}
{$form.$element_name_to.label} {$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>
- {if $element.data_type neq 'Date'}
- {$form.$element_name.html}
- {elseif $element.skip_calendar NEQ true }
- {include file="CRM/common/jcalendar.tpl" elementName=$element_name}
- {/if}
+ {$form.$element_name.html}
{if !empty($form.$operator_name)}
<span class="crm-multivalue-search-op" for="{$element_name}">{$form.$operator_name.html}</span>
{assign var="add_multivalue_js" value=true}
{include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n}
{elseif $n eq 'email_greeting' or $n eq 'postal_greeting' or $n eq 'addressee'}
{include file="CRM/Profile/Form/GreetingType.tpl"}
- {elseif ( $field.data_type eq 'Date' AND $element.skip_calendar NEQ true ) or
- ( $n|substr:-5:5 eq '_date' ) or ( $field.name eq 'activity_date_time' ) }
+ {elseif ( $n|substr:-5:5 eq '_date' ) or ( $field.name eq 'activity_date_time' ) }
{include file="CRM/common/jcalendar.tpl" elementName=$form.$n.name}
{elseif $n|substr:0:5 eq 'phone'}
{assign var="phone_ext_field" value=$n|replace:'phone':'phone_ext'}