dianping/cat · error · Error

Must choose at least one picker

Error message

Must choose at least one picker

What it means

During init() the picker validates that at least one of the options pickDate or pickTime is true — a widget that shows neither date nor time is meaningless, so it throws. This commonly happens indirectly via dataToOptions(), which reads HTML5 data attributes (data-date-picker / data-time-picker style attributes) that can override the JS options with falsey strings.

Source

Thrown at cat-home/src/main/webapp/assets/js/uncompressed/date-time/bootstrap-datetimepicker.js:99

		    date: 'glyphicon glyphicon-calendar',
		    up: 'glyphicon glyphicon-chevron-up',
		    down: 'glyphicon glyphicon-chevron-down'
		},

        picker = this,

        init = function () {

            var icon = false, i, dDate, longDateFormat;
            picker.options = $.extend({}, defaults, options);
            picker.options.icons = $.extend({}, icons, picker.options.icons);

            picker.element = $(element);

            dataToOptions();

            if (!(picker.options.pickTime || picker.options.pickDate))
                throw new Error('Must choose at least one picker');

            picker.id = dpgId++;
            pMoment.lang(picker.options.language);
            picker.date = pMoment();
            picker.unset = false;
            picker.isInput = picker.element.is('input');
            picker.component = false;

            if (picker.element.hasClass('input-group')) {
                if (picker.element.find('.datepickerbutton').size() == 0) {//in case there is more then one 'input-group-addon' Issue #48
                    picker.component = picker.element.find("[class^='input-group-']");
                }
                else {
                    picker.component = picker.element.find('.datepickerbutton');
                }
            }
            picker.format = picker.options.format;

View on GitHub (pinned to e815e74d4c)

Solutions

  1. Ensure exactly one (or both) of pickDate/pickTime stays true, e.g. time-only: {pickDate:false, pickTime:true}.
  2. Check data-* attributes on the input element that dataToOptions() reads, and remove ones that disable both.
  3. Use the correct camelCase option names pickDate and pickTime.

Example fix

// before
$('#dt').datetimepicker({ pickDate: false, pickTime: false }); // throws

// after
$('#dt').datetimepicker({ pickDate: false, pickTime: true }); // time-only
Defensive patterns

Strategy: validation

Validate before calling

var opts = $.extend({}, userOpts);
if (!opts.pickDate && !opts.pickTime) opts.pickDate = true; // never allow both false
$('#dt').datetimepicker(opts);

Type guard

function hasPickerMode(o) {
  return !!(o && (o.pickDate !== false || o.pickTime !== false));
}

Prevention

When it happens

Trigger: Passing {pickDate:false, pickTime:false}; setting data attributes like data-date-format pages carrying data-pick-date="false" and data-pick-time="false"; a typo such as pickdate/picktime (camelCase mismatch) leaving the real options false.

Common situations: Trying to build a time-only or date-only picker and accidentally disabling both; dataToOptions() parsing data attributes where 'false' string handling zeroes out both flags; copying option blocks between picker versions with renamed options.

Related errors


AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14). Data as JSON: /api/errors/bc34f3b6c64896c2. Report an issue: GitHub.