formio / formio.js

JavaScript powered Forms with JSON Form Builder

Home Page:https://formio.github.io/formio.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Confictional doesn't work for object

adhonay opened this issue · comments

To reproduce:
https://formio.github.io/formio.js/app/sandbox
Sandbox: 64c3c4d1c27319e1a1b2b486

I need to send the select value in object format { id, label }, but when I create a condition for the text field, to display it when the select value is 1, it doesn't work. This only works for when sending the pure value.

How could I make a conditional or logic via interface in the modal to hide a field, but sending an object?

No conditionals or advanced logic, just a simple interface.

it doesn't work like that. you have the storage type for select set to Object, which means it saves the value as
{id: x, label: "..."}

so for this you need a custom conditional:
"customConditional": "show = data.select.id === 1;

or set the storage type to number (to store the id of the option).

Got it, for me it would have some shape without being personalized, thanks!