# Collection link: display multiple fieldnames

**URL:** <https://discourse.getcockpit.com/t/collection-link-display-multiple-fieldnames/342>\
**Category:** Support\
**Created:** [October 17, 2018, 6:44pm UTC](https://discourse.getcockpit.com/t/collection-link-display-multiple-fieldnames/342 "2018-10-17T18:44:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![huleos](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/huleos/32/129_2.png) [@huleos](https://discourse.getcockpit.com/u/huleos)\
**Post date:** [October 17, 2018, 6:44pm UTC](https://discourse.getcockpit.com/t/collection-link-display-multiple-fieldnames/342/1 "2018-10-17T18:44:43Z")

</div>

Is it possible to show more **fieldnames** on the display?

```json
{
    "link": "collectionname",
    "display": [
    	"fieldname_1",
    	"fieldname_2"
    ],
    "multiple": false,
    "limit": false
}

```

---

<div class="post-metadata">

**Author:** ![theo](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@theo](https://discourse.getcockpit.com/u/theo)\
**Post date:** [November 9, 2019, 5:44pm UTC](https://discourse.getcockpit.com/t/collection-link-display-multiple-fieldnames/342/2 "2019-11-09T17:44:07Z")

</div>

Hi,  
I want to make same, i have try a trick with an Set field for display it on a json structure, but that not work on collection link view and display “{getDisplay(link)} or {Object}” label.

I’m new on this CMS, but after viewing this post : [Renderer for set field in backend](https://discourse.getcockpit.com/t/renderer-for-set-field-in-backend/372)  
I think this features is possible with a component.

---

<div class="post-metadata">

**Author:** ![qodrinzo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/qodrinzo/32/460_2.png) [@qodrinzo](https://discourse.getcockpit.com/u/qodrinzo)\
**Post date:** [December 27, 2019, 6:24pm UTC](https://discourse.getcockpit.com/t/collection-link-display-multiple-fieldnames/342/3 "2019-12-27T18:24:15Z")

</div>

This feature seems useful. I want to show “firstname” and “lastname” of linked entities; either has no meaning by itself.

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [January 10, 2020, 3:57pm UTC](https://discourse.getcockpit.com/t/collection-link-display-multiple-fieldnames/342/4 "2020-01-10T15:57:54Z")

</div>

I wrote a custom collectionlink field and added a string concat function.

Usage:

Copy the modified file to `/path/to/cockpit/config/tags/field-collectionlink.tag` and add your display field names in brackets. The string replacement is inspired by the set renderer.

```json
{
  "link": "persons",
  "display": "{first_name} {last_name}"
}

```

I didn’t test it with `"multiple":true`. Feel free, to send a pull request, if you find any issues.

> <https://github.com/raffaelj/cockpit-scripts/blob/master/custom-fields/field-collectionlink.tag>

  

> <https://github.com/raffaelj/cockpit-scripts/blob/master/custom-fields/field-collectionlink.md>

If you use such modified files, don’t forget to copy them to remote locations… and if you ask for help on discourse, don’t forget to mention, that your issues might differ from the default behaviour. And, obviously, custom tags won’t receive updates when you update cockpit.

---

<div class="post-metadata">

**Author:** ![sebastian\_berlin](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@sebastian\_berlin](https://discourse.getcockpit.com/u/sebastian_berlin)\
**Post date:** [July 3, 2022, 10:20am UTC](https://discourse.getcockpit.com/t/collection-link-display-multiple-fieldnames/342/5 "2022-07-03T10:20:19Z")

</div>

Thanks for writing that! It would help a lot.

But I’m afraid it’s not working if you refer to a field with a **collection-link**.

`{textfield} {collectionlinkfield}`

Instead of the display name the output of the 2n field is `[object Object]` …the first field is rendered regularly.

I’m aware that a collectionlink-field with **multiple** = true would be a bit tricky. But at least with _false_ the given display name would helpful instead of nothing or that cryptic message.

Could you please have a look?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [July 8, 2022, 10:44am UTC](https://discourse.getcockpit.com/t/collection-link-display-multiple-fieldnames/342/6 "2022-07-08T10:44:03Z")

</div>

First: I didn’t use that custom field for a long time, so I’m not sure, if there may be missing updates from the core field.

You can change

```nohighlight
str = str.replace('{'+k+'}', _entry[k]);

```

to

```nohighlight
if (typeof _entry[k] == 'string') {
    str = str.replace('{'+k+'}', _entry[k]);
}

```

in these two places:

> <https://github.com/raffaelj/cockpit-scripts/blob/master/custom-fields/field-collectionlink.tag#L475>

> <https://github.com/raffaelj/cockpit-scripts/blob/master/custom-fields/field-collectionlink.tag#L494>

Now it should at least prevent that object to string conversion, but I didn’t test it.

Feel free to send a pull request - or leave some feedback here after testing it locally.
