Closed caewok closed 1 year ago
There are a number of supported formats for the input to selectOptions
. What you are looking for in this case would be an input structure that looks like either:
let choices = {
a: "Choice A",
b: "Choice B"
}
with an invocation of:
{{selectOptions choices}}
OR
let choices = [
{id: "a", label: "Choice A"},
{id: "b", label: "Choice B"}
]
For the second format your invocataion needs to look like:
{{selectOptions choices nameAttr="id" labelAttr="label"}}
I don't think the example data structure posted in the original issue should be supported, I think both of the above options are more clear with regards to defining the options.
Perhaps we have a documentation problem here rather than a code problem.
Yes, having seen your suggested fix, I agree this is a documentation problem with how selectOption
handles array objects.
Where did you find it, or where does it belong for requests?
V10 API Documentation (https://foundryvtt.com/api/v10/)
What page or file needs a look at?
https://foundryvtt.com/api/classes/client.HandlebarsHelpers.html#selectOptions
What core version are you reporting this for?
Version 10.291
What is wrong, in your opinion?
Documentation suggests you can pass an array as choices to the Handlebars
selectOptions
helper:In testing and per this Discord discussion, passing an array of choices results in a blank (undefined) list of selections in the dropdown. Passing an object appears to work fine.