Untitled

 avatar
unknown
plain_text
2 months ago
1.2 kB
4
Indexable
function getAllFieldLabelNames(section_selectors = "") {
        var selector = "body";
        if (section_selectors) {
            selector = section_selectors;
        }
        let resultant_field_names = [];
        
        $(selector).find("input, textarea, select, a, button").filter(function () {
            return (($(this).closest("#amplify-modal").length == 0) && ($(this).attr("name")));
        }).each(function () {
            var fieldLabelName = "";
            var tagName = $(this).prop("tagName");

            if (tagName === "BUTTON" || tagName === "A") {
                fieldLabelName = $(this).html();
            } else {
                fieldLabelName = $(this).closest(".amplify-group, .amplify-form-group").find("label").html() || $(this).closest(".amplify-group, .amplify-form-group").find(".db-label").html() || $(this).closest(".amplify-group, .amplify-form-group").find(".amplify-form-label").html();
            }
    
            fieldLabelName = getText(fieldLabelName).trim();
            if (fieldLabelName && fieldLabelName != "undefined") {
                resultant_field_names.push(fieldLabelName);
            }
        });
    
        return [...new Set(resultant_field_names)];
    }    
Editor is loading...
Leave a Comment