# Unable to manipulate values in Editor control via oneditsave()

**URL:** https://discourse.nodered.org/t/unable-to-manipulate-values-in-editor-control-via-oneditsave/55681
**Category:** Developing Nodes
**Tags:** editor
**Created:** [25 December 2021 11:47 UTC](https://discourse.nodered.org/t/unable-to-manipulate-values-in-editor-control-via-oneditsave/55681 "2021-12-25T11:47:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kakyoism](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kakyoism/32/46283_2.png) [@kakyoism](https://discourse.nodered.org/u/kakyoism)
#### Post date: [25 December 2021 11:47 UTC](https://discourse.nodered.org/t/unable-to-manipulate-values-in-editor-control-via-oneditsave/55681/1 "2021-12-25T11:47:22Z")

</div>

With a custom node's parameter configuration editor, I'd like to convert a multi-line textarea's content from a single string to a list of strings, one per line.

Here is how I tried it with `mynode.html`

```auto
        oneditsave: function() {
            var node = this;
            var nameText = $("#node-input-names").val();
            var names = nameText.split('\n');
            console.log(`node: ${Array.isArray(names)}`);
            node.names = names;
        }

```

....

```auto
    <div class="form-tips"><i class="fa fa-hand-o-down"></i> user names</div>
    <div class="form-row">
    	<label for="node-input-names"><i class="fa fa-list"></i>Names</label>
        <textarea id="node-input-names" name="names">john smith</textarea>
    </div>

```

When saving the node in the editor, I can see the print out "node: true", meaning the text extracted from textarea has been converted to an array of strings.

However, in `mynode.js`, I plugged

```auto
function myNode(this, config) {
    ...
    console.log(`config.names is array: ${Array.isArray(config.names)}`);
    ...

```

This time I got

```auto
config.names is array: false

```

where I expect it to be

```auto
config.names is array: true

```

I also tried to set the textarea content in `oneditsave()` and that works as long as I provide a string to it.  
What am I missing? Is it that I'm not allowed to convert variable types there?

---

<div class="post-metadata">

### Author: ![kakyoism](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kakyoism/32/46283_2.png) [@kakyoism](https://discourse.nodered.org/u/kakyoism)
#### Post date: [26 December 2021 02:04 UTC](https://discourse.nodered.org/t/unable-to-manipulate-values-in-editor-control-via-oneditsave/55681/2 "2021-12-26T02:04:15Z")

</div>

The reason why I don't use an EditableList widget is because the lists in our cases are usually too big to fill in one by one by hand using the "add" button. I'd love to ask my users to use a plaintext format with one item per line, then convert it back to a list automatically using a parser on saving the configuration.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [26 December 2021 08:52 UTC](https://discourse.nodered.org/t/unable-to-manipulate-values-in-editor-control-via-oneditsave/55681/3 "2021-12-26T08:52:58Z")

</div>

As you have given the `textarea` an id of `node-input-names`, the editor will be using it's value when saving the values.

As you want to save a custom type, then give the textarea a different id - eg `node-input-names-raw`

Add code to `oneditprepare` that turns the array back to a block of text and set the value of the textarea.

The code you have for oneditsave should then work (once you change it to use the new textarea id)

---

<div class="post-metadata">

### Author: ![kakyoism](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kakyoism/32/46283_2.png) [@kakyoism](https://discourse.nodered.org/u/kakyoism)
#### Post date: [27 December 2021 09:14 UTC](https://discourse.nodered.org/t/unable-to-manipulate-values-in-editor-control-via-oneditsave/55681/4 "2021-12-27T09:14:48Z")

</div>

Thanks @knolleary for answering during the holidays!

Just to be sure I understand:

By renaming the textarea to `node-input-names-raw`, you mean I should make my html ui code look like this

```auto
    <div class="form-tips"><i class="fa fa-hand-o-down"></i> user names</div>
    <div class="form-row">
    	<label for="node-input-names-raw"><i class="fa fa-list"></i>Names</label>
        <textarea id="node-input-names-raw" name="names">john smith</textarea>
    </div>

```

This will not affect the way how `node.names` is parsed by JS as the config, correct?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [27 December 2021 09:46 UTC](https://discourse.nodered.org/t/unable-to-manipulate-values-in-editor-control-via-oneditsave/55681/5 "2021-12-27T09:46:57Z")

</div>

> [@kakyoism](#):
>
> This will not affect the way how `node.names` is parsed by JS as the config, correct?

As long as you use oneditprepare and oneditsave to get/set the value of `this.names` as I described, then it should just work.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [10 January 2022 09:47 UTC](https://discourse.nodered.org/t/unable-to-manipulate-values-in-editor-control-via-oneditsave/55681/6 "2022-01-10T09:47:22Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
