I have a use case where I need to add custom attributes to WFFM form fields. I have to add "aria-required" attribute to checkbox field if required is checked for a checkbox field.
I have created another class that inherits from wffm checkbox and have overridden the oninit() method.
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
var form = WebUtil.GetParent<SimpleForm>(this);
if (WFFMHelper.IsRequiredField(form, this.ControlName))
this.checkbox.Attributes.Add("aria-required", "true");
}
By this the "aria-required" attribute gets added to tag which contains the checkbox. The "aria-required" attribute purpose is lost if added to parent element instead of checkbox.
Please let me know there a way to add custom attributes to checkbox input directly.
Sitecore version 9.0.2 WFFM version 9.0