diff --git a/accessible_fix/module_fixes/webform.inc b/accessible_fix/module_fixes/webform.inc index 798ec9c..8316827 100644 --- a/accessible_fix/module_fixes/webform.inc +++ b/accessible_fix/module_fixes/webform.inc @@ -26,7 +26,13 @@ function accessible_fix_webform_element($variables) { $prefix = isset($element['#field_prefix']) ? '' . webform_filter_xss($element['#field_prefix']) . ' ' : ''; $suffix = isset($element['#field_suffix']) ? ' ' . webform_filter_xss($element['#field_suffix']) . '' : ''; - $children = ' ' . $prefix . $element['#children'] . $suffix; + + // Generate description for above or below the field. + $above = !empty($element['#webform_component']['extra']['description_above']); + $description = array( + FALSE => '', + TRUE => !empty($element['#description']) ? '
' . $element['#description'] . "
\n" : '', + ); // Generate the title, either a legend or a label, only if the title will be used if (!in_array($element['#title_display'], array('none', 'attribute'))) { @@ -47,25 +53,26 @@ function accessible_fix_webform_element($variables) { switch ($element['#title_display']) { case 'inline': + $output .= $description[$above]; + $description[$above] = ''; + // FALL THRU. case 'before': case 'invisible': - $output .= $title . $children . "\n"; + $output .= $title . ' ' . $prefix . $description[$above] . $element['#children'] . $suffix . "\n"; break; case 'after': - $output .= $children . $title . "\n"; + $output .= ' ' . $prefix . $description[$above] . $element['#children'] . $suffix . $title . "\n"; break; case 'none': case 'attribute': // Output no label and no required marker, only the children. - $output .= $children . "\n"; + $output .= ' ' . $prefix . $description[$above] . $element['#children'] . $suffix . "\n"; break; } - if (!empty($element['#description'])) { - $output .= '
' . $element['#description'] . "
\n"; - } + $output .= $description[!$above]; if ($composite) { $output .= '';