Skip to content
Snippets Groups Projects
Unverified Commit 5d73950a authored by Eileen McNaughton's avatar Eileen McNaughton Committed by GitHub
Browse files

Merge pull request #16610 from mattwire/settingstrait_datepicker

Allow adding datepicker to metadata based settings pages
parents 4de71a02 12c73866
Branches
Tags
No related merge requests found
......@@ -227,7 +227,7 @@ trait CRM_Admin_Form_SettingTrait {
$this->addRadio($setting, $props['title'], [1 => ts('Yes'), 0 => ts('No')], CRM_Utils_Array::value('html_attributes', $props), '  ');
}
elseif ($add === 'add') {
$this->add($props['html_type'], $setting, $props['title'], $options);
$this->add($props['html_type'], $setting, $props['title'], $options, FALSE, $props['html_extra'] ?? NULL);
}
else {
$this->$add($setting, $props['title'], $options);
......@@ -290,7 +290,7 @@ trait CRM_Admin_Form_SettingTrait {
'advmultiselect' => 'Element',
];
$mapping += array_fill_keys(CRM_Core_Form::$html5Types, '');
return $mapping[$htmlType];
return $mapping[$htmlType] ?? '';
}
/**
......
......@@ -387,6 +387,14 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
}
// @see http://wiki.civicrm.org/confluence/display/CRMDOC/crmDatepicker
if ($type == 'datepicker') {
// Support minDate/maxDate properties
if (isset($extra['minDate'])) {
$extra['minDate'] = date('Y-m-d', strtotime($extra['minDate']));
}
if (isset($extra['maxDate'])) {
$extra['maxDate'] = date('Y-m-d', strtotime($extra['maxDate']));
}
$attributes = ($attributes ? $attributes : []);
$attributes['data-crm-datepicker'] = json_encode((array) $extra);
if (!empty($attributes['aria-label']) || $label) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment