# Objects type for theme setting

**URL:** https://meta.discourse.org/t/objects-type-for-theme-setting/305009
**Category:** Developer Guides
**Tags:** how-to, theme-guides
**Created:** [April 23, 2024, 6:24am UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009 "2024-04-23T06:24:06Z")
**Posts on this page:** 13
**Page:** 2

<div class="post-metadata">

### Author: ![mdoggydog](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@mdoggydog](https://meta.discourse.org/u/mdoggydog)
#### Post date: [February 8, 2025, 4:24am UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/24 "2025-02-08T04:24:14Z")

</div>

> [@tgxworld](#):
>
> Reordering is certainly something that has been brought up internally as well. I’ll try to land that this week.

Narrator: “It was not landed that week.” 🙃

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 22, 2025, 8:15am UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/25 "2025-07-22T08:15:43Z")

</div>

> [@tgxworld](#):
>
> Reordering is certainly something that has been brought up internally as well. I’ll try to land that this week.

Is there any change on this? I just re-wrote a component for someone using objects type and they are unhappy that they can’t reorder.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 27, 2025, 3:44pm UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/26 "2025-07-27T15:44:38Z")

</div>

Hey @awesomerobot do you think this going to get onto someone’s list any time soon? It doesn’t seem like anyone from team has looked at this in a year.

Also, it’s pretty terrible that they are all named “field\_name-X”. Would it be possible to have a field name that could get used there? Having to click every single one to see what’s there is a nightmare if you have more than a couple objects.

If we can’t re-order the items and you can’t tell what they are without clicking on them, I’m likely going to have to go back to using a single string setting with multiple values separated with, uh, some character to separate the different fields. And I think with the old-style arrays you could re-order stuff, right? So this objects type seems like a step backward for everyone except programmers.

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [July 28, 2025, 2:31pm UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/27 "2025-07-28T14:31:38Z")

</div>

I don’t think there’s anything in process for reordering at the moment, though it’s still something we’d like to include. Renaming is already possible with the `identifier` property. For example, from the custom header links theme component

> <https://github.com/discourse/discourse-custom-header-links/blob/main/settings.yml#L1C1-L6C21>

The name field is set as the identifier for each link, so you can see which link is which

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/1/1/1112256f4229c427483da0a5e230cd2943eb296f.png)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 28, 2025, 9:47pm UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/28 "2025-07-28T21:47:34Z")

</div>

> [@awesomerobot](#):
>
> Renaming is already possible with the `identifier` property

Hooray. I thought I must have overlooked that but have not managed to find it before. Thanks!

EDIT: And now I used the `identifier` property and added an ‘order’ field, so it’s not too bad. I still think being able to reorder settings would be nice, and it’s available with arrays. . .

Thanks again for your help

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [September 29, 2025, 2:32pm UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/30 "2025-09-29T14:32:53Z")

</div>

> [@pfaffman](#):
>
> EDIT: And now I used the `identifier` property and added an ‘order’ field, so it’s not too bad. I still think being able to reorder settings would be nice, and it’s available with arrays. . .

I made [a commit](https://github.com/discourse/discourse/commit/7ec6ffe3084445b7afbfb0f25e2f5e605952a1a7) a bit ago that adds re-ordering for objects. Here is a little test setting to show the buttons:

 ![Screenshot 2025-09-29 at 9.30.03 AM](https://global.discourse-cdn.com/meta/original/4X/8/5/6/856ceeb3c439f06d21a76821766ac468b9d7e377.jpeg)

---

<div class="post-metadata">

### Author: ![gabriel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gabriel/32/367911_2.png) [@gabriel](https://meta.discourse.org/u/gabriel)
#### Post date: [December 2, 2025, 2:43pm UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/31 "2025-12-02T14:43:56Z")

</div>

I think it is worth announcing that we got `uploads` as a field type option now, and I think it was mentioned somewhere, but it is nice to mention again that `type: objects` works on both theme settings and in site settings(plugins)

---

<div class="post-metadata">

### Author: ![singi2016cn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/singi2016cn/32/532755_2.png) [@singi2016cn](https://meta.discourse.org/u/singi2016cn)
#### Post date: [March 9, 2026, 2:45am UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/32 "2026-03-09T02:45:51Z")

</div>

![image](https://global.discourse-cdn.com/meta/original/4X/5/b/c/5bc72785df5a8e058d552063f66ecca62538ff85.png)

The correct one should be `upload`

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [March 10, 2026, 1:38am UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/33 "2026-03-10T01:38:02Z")

</div>

Thank you! Will be fixed in

[https://github.com/discourse/discourse/pull/38398](https://github.com/discourse/discourse/pull/38398)

---

<div class="post-metadata">

### Author: ![singi2016cn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/singi2016cn/32/532755_2.png) [@singi2016cn](https://meta.discourse.org/u/singi2016cn)
#### Post date: [March 18, 2026, 8:17am UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/34 "2026-03-18T08:17:24Z")

</div>

Does the `objects` type support a `max` limit? I tried it, but it seems it doesn’t.

---

<div class="post-metadata">

### Author: ![gormus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gormus/32/428592_2.png) [@gormus](https://meta.discourse.org/u/gormus)
#### Post date: [April 12, 2026, 6:38pm UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/35 "2026-04-12T18:38:00Z")

</div>

Do you mean like for a `string` type field in a objects tree?  
Try `max_length`…

See [#Validations for `string` types](https://meta.discourse.org/t/objects-type-for-theme-setting/305009?silent=true#p-1502383-validations-for-string-types-4) on this topic; or a working example:

> <https://github.com/gormus/discourse-notification-banners/blob/03612783b114fa9fae943e2e969d6b7bc0651657/settings.yml#L24-L29>

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [April 12, 2026, 6:58pm UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/36 "2026-04-12T18:58:22Z")

</div>

I think he’s referring to:

> [@gormus](#):
>
> ` type: objects`

---

<div class="post-metadata">

### Author: ![singi2016cn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/singi2016cn/32/532755_2.png) [@singi2016cn](https://meta.discourse.org/u/singi2016cn)
#### Post date: [April 13, 2026, 1:45am UTC](https://meta.discourse.org/t/objects-type-for-theme-setting/305009/37 "2026-04-13T01:45:38Z")

</div>

Yes, I am referring to limiting the maximum number of items in the `objects` array.

Currently, this is not supported out of the box, so I extended the functionality in a custom private theme component. Here is the configuration (for reference only):

Configuration for maximum array count limit:

`themes/quectel-custom-homepage/settings.yml`

```yaml
banner_images:
  type: objects
  default: []
  schema:
    name: "Carousel"
    max: 9 // New extended configuration to limit the maximum number of items in the array
    identifier: image_url
    properties:
      image_url:
        type: upload
        required: true
      link_url:
        type: string
        min: 0
        max: 1023

```

Extended code:

`themes/quectel-custom-homepage/javascripts/discourse/api-initializers/quectel-custom-homepage.gjs`

```glimmer-javascript
import { action } from "@ember/object";
import { apiInitializer } from "discourse/lib/api";
import classPrepend from "discourse/lib/class-prepend";
import { i18n } from "discourse-i18n";

export default apiInitializer(() => {
  // Use classPrepend to extend the SchemaSettingNewEditor component to support the max limit for objects type
  // Load this component only in the admin context
  let SchemaSettingNewEditor;
  try {
    SchemaSettingNewEditor =
      require("discourse/admin/components/schema-setting/editor").default;
  } catch {
    // Non-admin users cannot load this component, skip extension
    return;
  }

  classPrepend(SchemaSettingNewEditor, (Superclass) => {
    return class extends Superclass {
      @action
      addItem() {
        // Check if the max limit is reached
        const maxLimit = this.args.setting.max || this.activeSchema?.max;

        if (maxLimit && this.activeData.length >= maxLimit) {
          this.validationErrorMessage = i18n(
            themePrefix("theme_settings.errors.objects_value_not_valid_max"),
            {
              count: maxLimit,
            }
          );
          return;
        }

        return super.addItem(...arguments);
      }

      @action
      addChildItem(propertyName, parentNodeIndex) {
        const propertySchema = this.activeSchema.properties[propertyName];

        // Check if the max limit is reached
        if (
          propertySchema?.max &&
          this.activeData[parentNodeIndex][propertyName].length >=
            propertySchema.max
        ) {
          this.validationErrorMessage = i18n(
            themePrefix("theme_settings.errors.objects_value_not_valid_max"),
            {
              count: propertySchema.max,
            }
          );
          return;
        }

        return super.addChildItem(...arguments);
      }
    };
  });
});

```

Theme translation configuration:

`themes/quectel-custom-homepage/locales/en.yml`

```yaml
en:
  theme_settings:
    errors:
      objects_value_not_valid_max: "The number cannot exceed %{count}"

```

Actual effect:

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/f/7/cf7d47e0424f6113c9f27cf610c6346309ad5340.png)

1. Error message
2. Unable to add more items

[Previous page](https://meta.discourse.org/t/objects-type-for-theme-setting/305009.md?page=1)
