Skip to content

Commit

Permalink
[REF] Fix regression where adding any date based field onto a profile…
Browse files Browse the repository at this point in the history
… triggers an error date preferences not configured when previewing the profile
  • Loading branch information
seamuslee001 committed Jul 27, 2020
1 parent 478d146 commit db91a58
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ public function &add(
// @see https://docs.civicrm.org/dev/en/latest/framework/ui/#date-picker
if ($type === 'datepicker') {
$attributes = $attributes ?: [];
if (!empty($attributes['format'])) {
$dateAttributes = CRM_Core_SelectValues::date($attributes['format'], NULL, NULL, NULL, 'Input');
if (!empty($attributes['formatType'])) {
$dateAttributes = CRM_Core_SelectValues::date($attributes['formatType'], NULL, NULL, NULL, 'Input');
if (empty($extra['minDate']) && !empty($dateAttributes['minYear'])) {
$extra['minDate'] = $dateAttributes['minYear'] . '-01-01';
}
Expand Down Expand Up @@ -1394,7 +1394,7 @@ public function addDatePickerRange($fieldName, $label, $isDateTime = FALSE, $req
$required,
['class' => 'crm-select2']
);
$attributes = ['format' => 'searchDate'];
$attributes = ['formatType' => 'searchDate'];
$extra = ['time' => $isDateTime];
$this->add('datepicker', $fieldName . $from, ts($fromLabel), $attributes, $required, $extra);
$this->add('datepicker', $fieldName . $to, ts($toLabel), $attributes, $required, $extra);
Expand Down Expand Up @@ -1649,7 +1649,7 @@ public function addField($name, $props = [], $required = FALSE, $legacyDate = TR
}
else {
$fieldSpec = CRM_Utils_Date::addDateMetadataToField($fieldSpec, $fieldSpec);
$attributes = ['format' => $fieldSpec['html']['formatType']];
$attributes = ['format' => $fieldSpec['date_format']];
return $this->add('datepicker', $name, $label, $attributes, $required, $fieldSpec['datepicker']['extra']);
}

Expand Down

0 comments on commit db91a58

Please sign in to comment.