Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After load form and the first running function in the 'events > change' in the select field the validation stops work #774

Open
typo3ua opened this issue Jan 18, 2023 · 0 comments

Comments

@typo3ua
Copy link

typo3ua commented Jan 18, 2023

I have simple form...

$(document).ready(function() { 
    var data = {
        "actionReal": "One or Two",
        "firstName": "First Name",
        "lastName": "Last Name"
    };
    var schema = {
        "title":"Form title",
        "type":"object",
        "properties": {
            "actionReal": {
                "type": "string",
                "required": true,
                "default": "none"
            },
            "firstName": {
                "required": true
            },
            "lastName": {
                "required": true
            }
        }
    };
    var options = {
        "fields": {
            "actionReal": {
                "type": "select",
                "label": "Your action",
                "noneLabel": "Select action...",
                "dataSource": [
                    {
                        "value": "one",
                        "text": "Action One"
                    },
                    {    
                        "value": "two",
                        "text": "Action Two"
                    }
                ],
                "events": {
                    "change": function() {
                        var firstName = this.parent.childrenByPropertyId["firstName"],
                            lastName = this.parent.childrenByPropertyId["lastName"];
                        actionReal = this.getValue();
                        if (actionReal === 'one') {
                            firstName.options.label = "First Name Action One";
                            lastName.options.label = "Last Name Action One";
                        } else {
                            firstName.options.label = "First Name Action Two";
                            lastName.options.label = "Last Name Action Two";
                        }
                        firstName.refresh();
                        lastName.refresh();
                    }
                },
                "removeDefaultNone": false,
                "validate": true
            },
            "firstName": {
                "type": "text",
                "label": "First Name Action Two",
                "validate": true
            },
            "lastName": {
                "type": "text",
                "label": "Last Name Action Two",
                "validate": true
            }
        },
    };
    $("#form").alpaca({
            "data": data,
            "schema": schema,
            "options": options,
            "type": "create"
    });
});

When I selected in the field Your action the value Action one the validation stops work, but when I selected in the field Your action another value then the validation works well... Can someone tell me what is wrong in my form?

Guys I need your help in resolve the issue, please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant