Commit e9f229db authored by eileen's avatar eileen

CRM-19490: Profile date fields don't respect localisation on the Contribution...

CRM-19490: Profile date fields don't respect localisation on the Contribution Page confirmation screen
parent a7aed606
......@@ -56,6 +56,10 @@ function smarty_modifier_crmDate($dateString, $dateFormat = NULL, $onlyTime = FA
$config = CRM_Core_Config::singleton();
$dateFormat = $config->dateformatTime;
}
// Handle possibility we only have a date function style date format.
if ($dateFormat && !stristr('%', $dateFormat)) {
return date($dateFormat, strtotime($dateString));
}
return CRM_Utils_Date::customFormat($dateString, $dateFormat);
}
......
......@@ -1775,20 +1775,22 @@ class CRM_Utils_Date {
public static function addDateMetadataToField($fieldMetaData, $field) {
if (isset($fieldMetaData['html'])) {
$field['html_type'] = $fieldMetaData['html']['type'];
if ($field['html_type'] === 'Select Date' && !isset($field['date_format'])) {
$dateAttributes = CRM_Core_SelectValues::date($fieldMetaData['html']['formatType'], NULL, NULL, NULL, 'Input');
$field['start_date_years'] = $dateAttributes['minYear'];
$field['end_date_years'] = $dateAttributes['maxYear'];
$field['date_format'] = $dateAttributes['format'];
$field['is_datetime_field'] = TRUE;
$field['time_format'] = $dateAttributes['time'];
$field['php_datetime_format'] = CRM_Utils_Date::getPhpDateFormatFromInputStyleDateFormat($field['date_format']);
if ($field['time_format']) {
$field['php_datetime_format'] .= ' H-i-s';
if ($field['html_type'] === 'Select Date') {
if (!isset($field['date_format'])) {
$dateAttributes = CRM_Core_SelectValues::date($fieldMetaData['html']['formatType'], NULL, NULL, NULL, 'Input');
$field['start_date_years'] = $dateAttributes['minYear'];
$field['end_date_years'] = $dateAttributes['maxYear'];
$field['date_format'] = $dateAttributes['format'];
$field['is_datetime_field'] = TRUE;
$field['time_format'] = $dateAttributes['time'];
$field['php_datetime_format'] = CRM_Utils_Date::getPhpDateFormatFromInputStyleDateFormat($field['date_format']);
if ($field['time_format']) {
$field['php_datetime_format'] .= ' H-i-s';
}
}
$field['datepicker']['extra'] = self::getDatePickerExtra($field);
$field['datepicker']['attributes'] = self::getDatePickerAttributes($field);
}
$field['datepicker']['extra'] = self::getDatePickerExtra($field);
$field['datepicker']['attributes'] = self::getDatePickerAttributes($field);
}
return $field;
}
......
......@@ -93,12 +93,15 @@
( $form.formName neq 'Confirm' ) AND
( $form.formName neq 'ThankYou' ) }
{include file="CRM/common/jcalendar.tpl" elementName=$profileFieldName}
{elseif ( $profileFieldName|substr:-5:5 eq '_date' ) }
{elseif $field.is_datetime_field && $action == 4}
{assign var="date_value" value=$form.$profileFieldName.value}
<span class="crm-frozen-field">
{$date_value|date_format:"%Y-%m-%d"|crmDate:$config->dateformatshortdate}
<input type="hidden" name="{$form.$profileFieldName.name}" value="{$form.$profileFieldName.value}" id="{$form.$profileFieldName.name}">
</span>
{$date_value|date_format:"%Y-%m-%d"|crmDate:$field.php_datetime_format}
<input type="hidden"
name="{$form.$profileFieldName.name}"
value="{$form.$profileFieldName.value}" id="{$form.$profileFieldName.name}"
>
</span>
{elseif $profileFieldName|substr:0:5 eq 'phone'}
{assign var="phone_ext_field" value=$profileFieldName|replace:'phone':'phone_ext'}
{if $prefix}{$form.$prefix.$profileFieldName.html}{else}{$form.$profileFieldName.html}{/if}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment