Descriptive repeater rows - how?

#1

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.

#2

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!

2 Likes
#3

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

“display”: “name”

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

#4

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

#5

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"
        }
      ]
    }
  }
}
#6

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

#7

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