formio.js icon indicating copy to clipboard operation
formio.js copied to clipboard

Path in conditional handled different on server/client

Open tkalmar opened this issue 1 year ago • 3 comments

Describe the bug When i have the following form definition:

{
    "display": "form",
    "settings": {
        "pdf": {
            "id": "1ec0f8ee-6685-5d98-a847-26f67b67d6f0",
            "src": "https://files.form.io/pdf/5692b91fd1028f01000407e3/file/1ec0f8ee-6685-5d98-a847-26f67b67d6f0"
        }
    },
    "components": [
        {
            "label": "first",
            "tableView": false,
            "validateWhenHidden": false,
            "key": "first",
            "type": "container",
            "input": true,
            "components": [
                {
                    "label": "nested",
                    "tableView": false,
                    "validateWhenHidden": false,
                    "key": "nested",
                    "type": "container",
                    "input": true,
                    "components": [
                        {
                            "label": "Checkbox",
                            "tableView": false,
                            "validateWhenHidden": false,
                            "key": "checkbox",
                            "type": "checkbox",
                            "input": true
                        },
                        {
                            "label": "Text Field",
                            "applyMaskOn": "change",
                            "tableView": true,
                            "validateWhenHidden": false,
                            "key": "textField",
                            "conditional": {
                                "show": true,
                                "when": "nested.checkbox",
                                "eq": "true"
                            },
                            "type": "textfield",
                            "input": true
                        }
                    ]
                }
            ]
        },
        {
            "type": "button",
            "label": "Submit",
            "key": "submit",
            "disableOnInvalid": true,
            "input": true,
            "tableView": false
        }
    ]
}

The form renderer toggles the visibility of the textfield. When i submit this form, the value of the textbox is lost, because on the server the visibility is determined as not visible and the value is cleared. So either the conditional calculation on the client is broken, and allows subpaths, or the calculation on the server side can't handle subpaths for visibility calculation.

Version/Branch

5.0.0-rc.91 at least also experienced in 4.0.2

To Reproduce

Create a Form with the given definition and submit it. The value for first.nested.textfield is lost

Expected behavior A clear and concise description of what you expected to happen. Either the toggling on client side should not work, or the server should not discard the value.

tkalmar avatar Oct 30 '24 11:10 tkalmar

@tkalmar The value of the textField is lost because the conditionals should be like

 "conditional": {
                                "show": true,
                                "when": "first.nested.checkbox",
                                "eq": "true"
                            }

Let us know if you still have questions.

VikkiAlenn avatar Nov 14 '24 13:11 VikkiAlenn

@VikkiAlenn Yeah, that im aware of. The question is why is this "working" in the gui? Shouldn't the toggle in the guy also not work? The path behaves different in the gui ...

tkalmar avatar Nov 14 '24 20:11 tkalmar

@tkalmar Thank you for your contribution! We created a ticket for our dev team. For the reference: FIO-9380.

VikkiAlenn avatar Nov 20 '24 14:11 VikkiAlenn