Skip to content

normalizeFieldsForForm() function through an error #47

Description

@walid-ajaj

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions