Best answer

Visual label for an Input Field with children uses `key` and not `label`

  • 11 November 2021
  • 1 reply
  • 216 views

Userlevel 1

When creating an Input Field that will have `children`, the children are displayed inside a little container/box under the parent. This is great.

 

The parent field still requires a `key` value, which I believe ends up being irrelevant / not used in the resulting `bundle.inputData`. This makes sense since the data gets mapped to the `key`s of each of the `children`.

 

However, the value that gets displayed for the surrounding box appears to come from the parent’s `key` and not the `label` property. Which seems unintuitive and less flexible to me.

 

Psuedo-code example:

{
// This gets converted to Capital Case (or something) and used for display
"key": "snake_case_key",
// This does not get used at all...why not?
"label": "Why don't you use me?",
"children": [
{
"key": "child_one",
"label": "I'm Child One",
"type": "string"
}
]
}

A screenshot that shows what I mean (not from that psuedo-code obviously):

 

icon

Best answer by Zane 15 November 2021, 19:40

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +9

This is correct, the Zap Editor uses the key as the display for line item groups, rather than label.

We’ll do better to document that.

Agree it’s not optimal. But it’s been working that way for so long now that if we just switched to using label, we’d likely see some surprising results where label never ended up getting tested. So it’d need to be a breaking change event, and we try to introduce those sparingly.

Side topic: Note that line item groups are meant for mapping input that you expect to be in an array. The platform will emit a corresponding array as output to your API. The emitted array will be named according to the key of the line item group. You’d mentioned

The parent field still requires a `key` value, which I believe ends up being irrelevant / not used in the resulting `bundle.inputData`.

So I wanted to point out that the key is significant when handling line item groups.