{"record":{"id":"bc34f3b6c64896c2","repo":"dianping/cat","slug":"must-choose-at-least-one-picker","errorCode":null,"errorMessage":"Must choose at least one picker","messagePattern":"Must choose at least one picker","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/uncompressed/date-time/bootstrap-datetimepicker.js","lineNumber":99,"sourceCode":"\t\t    date: 'glyphicon glyphicon-calendar',\n\t\t    up: 'glyphicon glyphicon-chevron-up',\n\t\t    down: 'glyphicon glyphicon-chevron-down'\n\t\t},\n\n        picker = this,\n\n        init = function () {\n\n            var icon = false, i, dDate, longDateFormat;\n            picker.options = $.extend({}, defaults, options);\n            picker.options.icons = $.extend({}, icons, picker.options.icons);\n\n            picker.element = $(element);\n\n            dataToOptions();\n\n            if (!(picker.options.pickTime || picker.options.pickDate))\n                throw new Error('Must choose at least one picker');\n\n            picker.id = dpgId++;\n            pMoment.lang(picker.options.language);\n            picker.date = pMoment();\n            picker.unset = false;\n            picker.isInput = picker.element.is('input');\n            picker.component = false;\n\n            if (picker.element.hasClass('input-group')) {\n                if (picker.element.find('.datepickerbutton').size() == 0) {//in case there is more then one 'input-group-addon' Issue #48\n                    picker.component = picker.element.find(\"[class^='input-group-']\");\n                }\n                else {\n                    picker.component = picker.element.find('.datepickerbutton');\n                }\n            }\n            picker.format = picker.options.format;\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/uncompressed/date-time/bootstrap-datetimepicker.js#L81-L117","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure exactly one (or both) of pickDate/pickTime stays true, e.g. time-only: {pickDate:false, pickTime:true}.","Check data-* attributes on the input element that dataToOptions() reads, and remove ones that disable both.","Use the correct camelCase option names pickDate and pickTime."],"exampleFix":"// before\n$('#dt').datetimepicker({ pickDate: false, pickTime: false }); // throws\n\n// after\n$('#dt').datetimepicker({ pickDate: false, pickTime: true }); // time-only","handlingStrategy":"validation","validationCode":"var opts = $.extend({}, userOpts);\nif (!opts.pickDate && !opts.pickTime) opts.pickDate = true; // never allow both false\n$('#dt').datetimepicker(opts);","typeGuard":"function hasPickerMode(o) {\n  return !!(o && (o.pickDate !== false || o.pickTime !== false));\n}","tryCatchPattern":null,"preventionTips":["Use exactly one of {pickDate:true, pickTime:false} or {pickDate:false, pickTime:true} from named constants.","Audit data-* attributes on inputs — dataToOptions() can silently override your JS options.","Use camelCase option names pickDate/pickTime."],"tags":["datetimepicker","configuration","options","vendor"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}