What I did was modify one of the custom fields to be for date. Took a while to figure out how flatpickr was being initialized. It starts with functions in assets/js/utils/ui.js
In /application/views/components/custom_fields.php I had it check if the field name had the word date in it. If it did it would set the date class to include "custom-date-field"
AI generated code
=============================================
<?php
/**
* Local variables.
*
* @var bool $disabled (false)
*/
$disabled = $disabled ?? false; ?>
<?php for ($i = 1; $i <= 5; $i++): ?>
<?php if (setting('display_custom_field_' . $i)): ?>
<?php
// Get the label text
$label = setting('label_custom_field_' . $i) ?: lang('custom_field') . ' #' . $i;
// Decide if this is a date field
$isDateField = (stripos($label, 'date') !== false);
?>
<div class="mb-3">
<label for="custom-field-<?= $i ?>" class="form-label">
<?= $label ?>
<?php if (setting('require_custom_field_' . $i)): ?>
<span class="text-danger" <?= $disabled ? 'hidden' : '' ?>>*</span>
<?php endif; ?>
</label>
<input type="text" id="custom-field-<?= $i ?>"
<Field ? ' custom-date-field' : '' ?>"
maxlength="120" <?= $disabled ? 'disabled' : '' ?>/>
</div>
<?php endif; ?>
<?php endfor; ?>
==============================================
Then in assets/js/pages/booking.js
I added
==========================================
const $customDates = $('.custom-date-field');
=========================================
where the variables are.
In the same file above the
======================================
App.Utils.UI.initializeDatePicker($selectDate, {
=======================================
I added
=============================================
App.Utils.UI.initializeDatePicker($customDates);
=============================================
Which triggers date picker for fields with the class custom-date-fields. Seems to work well. I will try to do the same or similar in the backend form for editing appointments. It doesn't change the database field type or anything but it should be fine. No need to get more complicated if you have custom fields available IMO. I think if you change ID instead of class it might break it getting inserted into the database, not sure.