# Custom fields - How to access field options inside \`this.$updateValue\`?

**URL:** <https://discourse.getcockpit.com/t/custom-fields-how-to-access-field-options-inside-this-updatevalue/599>\
**Category:** Support\
**Created:** [February 22, 2019, 12:57pm UTC](https://discourse.getcockpit.com/t/custom-fields-how-to-access-field-options-inside-this-updatevalue/599 "2019-02-22T12:57:24Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [February 22, 2019, 12:57pm UTC](https://discourse.getcockpit.com/t/custom-fields-how-to-access-field-options-inside-this-updatevalue/599/1 "2019-02-22T12:57:24Z")

</div>

I try to modify some data inside a custom field. The simplified structure is:

- data structure: `(string) "1|2|5|8"`
- field options: `{"separator": "|"}`

```auto
this.$updateValue = function(value, field) {

    // value = (string) "1|2|5|8"
    // field = (string) "entry.my_field_name"

    if (typeof value == 'string') { // opts.separator is undefined
        value = value.split(opts.separator ? opts.separator : ',');
    }

    // some more checks...

    if (JSON.stringify(this.selected) != JSON.stringify(value)) {
        this.selected = value;
        this.update();
    }

}.bind(this);

```

How can I access the field options inside this function? It’s somehow defined in [riot.bind.js](https://github.com/agentejo/cockpit/blob/next/assets/lib/riot/riot.bind.js), but I don’t understand it. I tried to assign variables in `this.on('mount', ...)`, in `this.on('update', ...)`, at the top of the script, with all variations of `this.opts` and `$this.opts` … nothing worked.

@artur Can you give me a hint, please?

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [February 25, 2019, 1:56am UTC](https://discourse.getcockpit.com/t/custom-fields-how-to-access-field-options-inside-this-updatevalue/599/2 "2019-02-25T01:56:33Z")

</div>

it should be just `opts`

---

<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:** [February 25, 2019, 7:36am UTC](https://discourse.getcockpit.com/t/custom-fields-how-to-access-field-options-inside-this-updatevalue/599/3 "2019-02-25T07:36:30Z")

</div>

It seems, that `opts` aren’t really available, at this moment. Or maybe it’s my Firefox again… I solved the problem by casting the values as array in my find function. On the PHP side I had access to the options.

edit:  
And some background… I resolved many-to-many relations from a SQL database with `GROUP_CONCAT`. For now there are only comma separated numeric id numbers, but it is possible to have different data and then I need to adjust the separator while fetching the data and while displaying it.
