if ($element->getAttribute('data-api-entity') && $element->getAttribute('data-entity-value')) {
$this->renderFrozenEntityRef($el, $element);
}
- elseif ($element->getAttribute('type') == 'text' && $element->getAttribute('format')) {
- $this->renderFrozenDate($el, $element);
+ elseif ($element->getAttribute('type') == 'text' && $element->getAttribute('formatType')) {
+ list($date, $time) = CRM_Utils_Date::setDateDefaults($element->getValue(), $element->getAttribute('formatType'), $element->getAttribute('timeformat'));
+ $el['html'] = $date . ' ' . $time . '<input type="hidden" value="' . $element->getValue() . '" name="' . $element->getAttribute('name') . '">';
}
$el['html'] = '<span class="crm-frozen-field">' . $el['html'] . '</span>';
$el['html'] = implode('; ', $display) . '<input type="hidden" value="' . $field->getValue() . '" name="' . $field->getAttribute('name') . '">';
}
- /**
- * Render a date field as text.
- *
- * @param array $el
- * @param HTML_QuickForm_element $field
- */
- public function renderFrozenDate(&$el, $field) {
- $format = $field->getAttribute('format');
- $map = CRM_Core_SelectValues::datePluginToPHPFormats($format);
-
- if (isset($map[$format])) {
- $format = $map[$format];
- }
-
- $date = DateTime::createFromFormat('d/m/Y', $field->getValue());
- $el['html'] = $date->format($format) . '<input type="hidden" value="' . $field->getValue() . '" name="' . $field->getAttribute('name') . '">';
- }
-
/**
* Pre-fill contact name for a custom field of type ContactReference
*