dianping/cat · error · Error
prompt with select requires options
Error message
prompt with select requires options
What it means
For prompt dialogs with inputType 'select', bootbox builds <option> elements from options.inputOptions and throws if that array is missing or empty — a select with no options would render a dead control, so it fails fast. inputOptions defaults to [] when absent, which also trips this check.
Source
Thrown at cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js:466
input = $(templates.inputs[options.inputType]);
switch (options.inputType) {
case "text":
case "textarea":
case "email":
case "date":
case "time":
case "number":
case "password":
input.val(options.value);
break;
case "select":
var groups = {};
inputOptions = options.inputOptions || [];
if (!inputOptions.length) {
throw new Error("prompt with select requires options");
}
each(inputOptions, function(_, option) {
// assume the element to attach to is the input...
var elem = input;
if (option.value === undefined || option.text === undefined) {
throw new Error("given options in wrong format");
}
// ... but override that element if this option sits in a group
if (option.group) {
// initialise group if necessary
if (!groups[option.group]) {
groups[option.group] = $("<optgroup/>").attr("label", option.group);View on GitHub (pinned to e815e74d4c)
Solutions
- Guard before calling: only open the prompt when the list has entries — if (!items.length) { bootbox.alert('Nothing to choose from.'); return; }
- Load the options first (AJAX/promise), then build the prompt in the completion handler.
- Verify the property name is exactly inputOptions and each entry has both value and text (see the follow-on format error).
Example fix
// before
bootbox.prompt({ title: 'Assign owner', inputType: 'select', callback: assign }); // inputOptions forgotten
// after
bootbox.prompt({
title: 'Assign owner', inputType: 'select',
inputOptions: owners.map(function (o) { return { value: o.id, text: o.name }; }),
callback: assign
}); Defensive patterns
Strategy: validation
Validate before calling
if (!Array.isArray(items) || !items.length) {
bootbox.alert('Nothing to choose from.');
return;
}
bootbox.prompt({ title: title, inputType: 'select',
inputOptions: items.map(function (i) { return { value: i.id, text: i.name }; }),
callback: cb }); Type guard
function hasNonEmptyInputOptions(o) {
return Array.isArray(o.inputOptions) && o.inputOptions.length > 0;
} Prevention
- Load option data before opening the prompt
- Property name must be exactly inputOptions
- Handle the legitimately-empty-list case with an alert instead
When it happens
Trigger: bootbox.prompt({title: 'Choose', inputType: 'select', callback: fn}) with no inputOptions; inputOptions: [] because the data source (AJAX list, query results) returned nothing or had not loaded yet; inputOptions passed under a wrong property name (options, values).
Common situations: Feeding inputOptions from an async source and calling prompt before the data arrives; filtering a list that legitimately becomes empty; misspelling the property so the default [] is used.
Related errors
- prompt with checkbox requires options
- given options in wrong format
- prompt requires a title
- prompt requires a callback
- invalid prompt type
AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14).
Data as JSON: /api/errors/b1a1e0f96501c0c2.
Report an issue: GitHub.