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