sitecoreweb-forms-for-marketers

WFFM form tag has role attribute which is redundant


The tag produced by WFFM contains the attribute role="form".

This is considered a redundant attribute and is causing issues for our site accessibility scan.

Here are the specifics from the accessibility scan...

A WAI-ARIA attribute that has the exact same features as the HTML element it has been applied to has been used. The WAI-ARIA attribute is redundant since is doesn't provide the user with any additional information.

Looking at the MVC form rendering that is installed with WFF, I see it points to the following class and method - Sitecore.Forms.Mvc.Controllers.FormController, Sitecore.Forms.Mvc.

Decompiling that class I can see their is a Sitecore.Forms.Mvc.Constants class which contains several attributes of the rendered form element, but not the role="form" attribute.

Would anyone know where Sitecore might be adding the attribute role to the form element?


Solution

  • Check the Views\Form\EditorTemplates\FormViewModel.cshtml file.

    You will see there:

    var attributes = new RouteValueDictionary()
    {
        { "enctype", "multipart/form-data" },
        { "class", @Model.CssClass },
        { "id", Model.ClientId },
        { "role", "form" },
        { Constants.Wffm, Model.Item.ID }
    };
    

    and a bit lower those attributes (containing form role) are used in BeginRouteForm method:

    using (Html.BeginRouteForm(routeName, queryString, FormMethod.Post, attributes))