Descriptive repeater rows - how?

Is there a way to use more descriptive text on collapsed repeater fields, especially when reordering? It would be nice if you could specify fields from within the repeater to show, so that there is some information as to which row you’re actually moving… I tried playing with the “display” option, but it doesn’t seem to do anything.

Dug into the code and discovered the following:

If your repeater is of type: set - you can add display at the root of your field config object, referencing the name of one of your set fields.

If your repeater contains a single field, you add display inside field.options and set the value to $value.

Love that this is possible, hate that it’s not in the docs!

3 Likes

Can you show your actual JSON, as I tried multiple ways without luck:

“display”: “name”

“display”: “bp_title” //name of item in set

Better if you show yours and we can try to fix it :slight_smile:

Thanks.

Here’s what I’ve tried:

{
  "field": {
    "type": "set",
    "name": "best_practice",
    "label": "Best Practice",
    "options": {
      "display": "bp_title",
      "fields": [
        {
          "name": "bp_title",
          "type": "text",
          "label": "Title"
        },
        {
          "name": "bp_desc",
          "type": "wysiwyg",
          "label": "Description"
        }
      ]
    }
  }
}

I copied your JSON to test it and it works for me, so I’m guessing this might be down to which version of Cockpit you’re using. I use the dev version… here

Thanks for testing that. I hadn’t thought about version, as I’m using the latest stable.

Sorry to trouble you all on this, but I’m brand new to Cockpit (love it). Would you be able to provide the JSON for the setting that worked? I’m failing all over the place. (my ver 0.9.2)

It’s working for me with the current stable version if the display attribute is directly put into the field object:

{
  "field": {
    "type": "set",
    "display": "bp_title",
    "name": "best_practice",
    "label": "Best Practice",
    "options": {
      "fields": [
        {
          "name": "bp_title",
          "type": "text",
          "label": "Title"
        },
        {
          "name": "bp_desc",
          "type": "wysiwyg",
          "label": "Description"
        }
      ]
    }
  }
}

This is great, but I can’t seem to get the basic repeater field working with a single field as opposed to a set, the set code above works great. Here is what I’m trying, I also moved display into the field and also tried using “$value” as @wuh said above but still they just say “Amenity X”.

{
  "field": {
    "type": "text",
    "name": "name",
    "label": "Amenity"
  },
  "display": "name"
}