# Collectionlink returns string if empty instead of empty array

**URL:** <https://discourse.getcockpit.com/t/collectionlink-returns-string-if-empty-instead-of-empty-array/1792>\
**Category:** Support\
**Created:** [January 12, 2021, 10:03pm UTC](https://discourse.getcockpit.com/t/collectionlink-returns-string-if-empty-instead-of-empty-array/1792 "2021-01-12T22:03:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Metelyoff](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/metelyoff/32/762_2.png) [@Metelyoff](https://discourse.getcockpit.com/u/Metelyoff)\
**Post date:** [January 12, 2021, 10:03pm UTC](https://discourse.getcockpit.com/t/collectionlink-returns-string-if-empty-instead-of-empty-array/1792/1 "2021-01-12T22:03:31Z")

</div>

How to fix collectionlink? returns empty string if empty instead of empty array!!! It’s drive me crazy!!! Why it’s happen??? Why different types??? Plz help!!!

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/5c2fe6bf5d883a0eaf61154f772dd01bb5732a53.png)

---

<div class="post-metadata">

**Author:** ![abernh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/abernh/32/859_2.png) [@abernh](https://discourse.getcockpit.com/u/abernh)\
**Post date:** [July 7, 2021, 7:53am UTC](https://discourse.getcockpit.com/t/collectionlink-returns-string-if-empty-instead-of-empty-array/1792/2 "2021-07-07T07:53:54Z")

</div>

On which version did you encounter this issue?  
I was not able to reproduce your result with `""` empty string on the latest version - but I see a similar effect with `null` instead.

Testing on `0.12.1` shows the following result:

`linkcollection` / `linkcollectionselect`

1. with `{multiple: true}` - 3 states

- `null` - if there was never a link set for this entry+field
- `[]` - empty array if at least 1 link was once set set but meanwhile reset/removed again
- `[{LINK_OBJ},...]` - array of link objects if links are set

1. with `{multiple: false}` - 2 states

- `null` - if there is currently no link set yet / link was reset/removed
- `{LINK_OBJ}` - link object if a link is set

### Bug or feature

So one could argue it’s a _bug_ to show

- an empty array `[]` when multi-links were reset
- but `null` if there were never any links set

One could also argue it’s a _feature_ to know if there is `no-value-yet` vs `no-value-anymore`.

---

<div class="post-metadata">

**Author:** ![Hackbard](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/hackbard/32/854_2.png) [@Hackbard](https://discourse.getcockpit.com/u/Hackbard)\
**Post date:** [July 7, 2021, 11:42am UTC](https://discourse.getcockpit.com/t/collectionlink-returns-string-if-empty-instead-of-empty-array/1792/3 "2021-07-07T11:42:01Z")

</div>

🤣  
I think we should go with a Feature Request to have the same output null or [] 😉  
Thinks like that are frustrating when you have to figure it in FE
