How do I configure array objects in a plugin? I tried using json_schema, but object property configuration doesn’t support selectors like category; only text input is possible. Meanwhile, type: objects simply doesn’t work in plugin configurations at all.
Configuration for json_schema:
quectel_online_customer_category_customers:
default: "[]"
client: true
json_schema: QuectelOnlineCustomer::SiteSettings::CategoryCustomersJsonSchema
plugins/quectel-online-customer/lib/quectel_online_customer/site_settings/category_customers_json_schema.rb
# frozen_string_literal: true
module QuectelOnlineCustomer
module SiteSettings
class CategoryCustomersJsonSchema
def self.schema
@schema ||= begin
{
type: "array",
uniqueItems: true,
default: [],
items: {
type: "object",
title: "Category Customer Configuration",
additionalProperties: false, # Prevent submission of undefined fields
required: %w[category customers], # Both fields are required
properties: {
category: {
type: "category",
description: "The forum category to bind",
label: "Category"
},
customers: {
type: "usernames", # Multi-select users, replacing single username
description: "Customer accounts assigned to this category, supports multi-selection",
label: "Customer Users"
}
}
}
}
end
end
end
end
end
Yes, that is indeed possible. However, type:objects does not support type:category either. My requirement is to select both categories and groups.
Oh I see, so the object settings are added directly to your settings.yml you’d want to format it like this:
oauth2_category_example:
type: objects
default: []
area: "oauth2"
schema:
name: category_rule
identifier: name
properties:
name:
type: string
required: true
label: Rule name
description: A label for this rule
category:
type: categories
required: true
label: Category
description: The category this rule applies to
validations:
max: 1
groups:
type: groups
label: Groups
description: Groups associated with this category
Which would produce a category dropdown like this
Doesn’t type:category support single selection?
According to this configuration
quectel_online_customer_category_customer_group:
type: objects
default: []
schema:
name: "Category Customer Group"
identifier: name
properties:
name:
type: string
required: true
label: Name
description: Name
category:
type: categories
required: true
label: "Category"
description: "Category name. Please view it on the <a href=\"/categories\" target=\"_blank\">All Categories</a> page"
group_name:
type: groups
required: true
label: "Customer Service Group Name"
description: "Customer service group name (English characters). Please view it on the <a href=\"/admin/groups\" target=\"_blank\">Customer Service Groups</a> page"
I encountered the following error:
Error occurred:
- While rendering:
{{outlet}} for -top-level
-top-level
{{outlet}} for application
application
DiscourseRoot
{{outlet}} for admin
admin
{{outlet}} for admin.schema
schema
SchemaSettingNewEditor
SchemaSettingField
SchemaSettingTypeCategories
CategorySelector
section-link.gjs:149
Attempted to rerender, but the Ember application has had an unrecoverable error occur during render. You should reload the application after fixing the cause of the error.
categories.gjs:13
Uncaught (in promise) TypeError: this.args.value?.map is not a function
at SchemaSettingTypeCategories.<anonymous> (categories.gjs:13:9)
Is this related to my version?
Discourse v2026.1.4 — Commits · discourse/discourse · GitHub — Ember v6.6.0
do you have any stale configuration saved to the setting? could you try resetting it to the default with the reset button if it appears?
I don’t see a reset button. The page looks exactly like the screenshot, and the items under the category aren’t rendering.
Hmmm I’m not sure what would be going wrong there… I’ve tested the categories option with the objects type so I know it works, and it shouldn’t be an issue with your version. I still wonder if something is stuck in a bad state somewhere, can you try a separate setting with a new name just to test it out? is this on github or anywhere so I can try it?
type:categories is acceptable, but type:category is not.
However, the configuration below works well even when only a single selection is made, so type:category is no longer needed.
category:
type: categories
required: true
label: "Category"
description: "Category name"
validations:
max: 1