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

normalizeFieldsForForm() function through an error #47

Open
walid-ajaj opened this issue Apr 4, 2022 · 0 comments
Open

normalizeFieldsForForm() function through an error #47

walid-ajaj opened this issue Apr 4, 2022 · 0 comments

Comments

@walid-ajaj
Copy link

function normalizeFieldsForForm(form, index)

normalizeFieldsForForm() function through an error in case the element (input) had no name or id attributes

Below is my suggestion for the fix:

                var that = $(this)
                    ,idTemplateAttr = getOrSetTemplate(that,"id")
                    ,nameTemplateAttr = getOrSetTemplate(that, "name")
                    ,idAttr = that.attr("id")
                    ,nameAttr = that.attr("name")
                    
                /* Normalize field name attributes */
                newNameAttr = nameTemplateAttr ? nameTemplateAttr.replace(options.indexFormat, index) : nameAttr;
                that.attr("name", newNameAttr);

                /* Normalize field id attributes */
                newIdAttr = idTemplateAttr ? idTemplateAttr.replace(options.indexFormat, index) : idAttr;

                idAttr ? form.find("label[for='"+idAttr+"']").each(function(){
                    $(this).attr("for", newIdAttr);
                }) : null;
                that.attr("id", newIdAttr);
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