Add Legend to Text Format Fieldset I'm working on making a site I maintain WCAG AA compliant. One of the items I'm getting flagged for is "Every FIELDSET element must contain exactly one LEGEND element." This error shows up on every page that has a comment function. It turns out it is due to the Text Format option for the comment body:



I've tried DMPing $form from a form_alter hook, but I can't seem to find this field set anywhere, at least it doesn't seem to be in the comment-form form. 

The ID of that form Item is edit-comment-body-und-0-format--2, which when I check my DPM output, there is an entry in comment-body/0/#format, but it's null.

Where can I add a legend to this field set?
I got this to work like this:

function mymodule_process(&amp;$variables, $hook) {
  if($hook == 'comment_wrapper') {
    $variables['content']['comment_form']['comment_body'][LANGUAGE_NONE][0]['format']['#post_render'][] = '_mymodule_post_render_fieldset';
  }
}


function _mymodule_post_render_fieldset($content, $element) {
  $your_legend = '$0&lt;legend&gt;Your comment legend&lt;/legend&gt;'; // $0 is the full matched string
  return preg_replace('/&lt;fieldset[^&gt;]*&gt;/', $your_legend, $content);
}


Care to give this a try?