1

We're migrating* a website that uses http://dubrox.github.io/Multiple-Dates-Picker-for-jQuery-UI/ to store any combination of dates for an entry... (eg not just a single date or date range, can be lots of individual dates which aren't sequential)

What would be the best kind of field/setup to import these into?

I guess we could create a custom field type that implements the same multipicker as above as it's also based on the jQuery datepicker widget... but have never created a custom field type from scratch though... what is the best approach to this?

(*7000 entries to import via FeedMe, looks like every single date is added to an event table as an individual row and looked up via an id :zany_face:)

enter image description here

1
1

Instead of creating a custom field could you do it with a Matrix with each date going into a matrix row?

I've done something similar in the past for scheduling delivery dates for a Commerce order. Each order has a matrix field for delivery dates and each date (along with some other data) is added as a separate row.

3
  • That would work yes - only problem is for events that span 10-15 days it's quite a lot of work! Dec 1 '20 at 11:44
  • If it's specifically for events then have you considered using Verbb Events plugin instead? Although not sure how you'd get import the dates into it tbh.
    – foamcow
    Dec 1 '20 at 12:53
  • Love a Verbb plugin! Most of the events have tickets on Eventbrite or other platforms already, the venue is basically aggregating a bunch of events that various organisations have already set up on these platforms Dec 1 '20 at 13:44
1

enter image description here

I got this working fairly easily* by:

  1. Creating a custom module and custom field type based on the default Plain Text Field (similar to https://nystudio107.com/blog/creating-a-custom-field-in-craft-cms)
  2. Adding the https://dubrox.github.io/Multiple-Dates-Picker-for-jQuery-UI JS and CSS to an asset bundle as part of the same module
  3. Within the new custom field, after the field has been set up, instantiating a Multiple Dates Picker instance at the end of the field html, and being sure to set the separator to just a comma (rather than the default comma followed by a space)
{% js %}
    $('#{{ id|namespaceInputId|e('js') }}').multiDatesPicker({
    separator: ","
  });
{% endjs %}

* Partly because the Multiple Dates Picker piggybacks the jQuery UI stuff that Craft already include in the control panel :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.