Posted by Screenack on October 13, 2011 at 1:51pm
The concept of what I want to do is simple:
Using Drupal 7 + Webforms, I wish to move the "required marker" from after the field label, to after the label itself.
Consider this example:
Before:
<div id="webform-component-first-name" class="form-item webform-component webform-component-textfield webform-container-inline">
<label for="edit-submitted-first-name">First Name <span title="This field is required." class="form-required">*</span></label>
<input type="text" class="form-text required" maxlength="128" size="19" value="" name="submitted[first_name]" id="edit-submitted-first-name">
</div>After:
<div id="webform-component-first-name" class="form-item webform-component webform-component-textfield webform-container-inline">
<label for="edit-submitted-first-name">First Name </label>
<input type="text" class="form-text required" maxlength="128" size="19" value="" name="submitted[first_name]" id="edit-submitted-first-name"> <span title="This field is required." class="form-required">*</span>
</div>I've successfully overridden the webform theme_webform_element() in my template.php. I see this line:
$required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : '';
But I don't see where I can move it's output?

Comments
You might be able to alter
You might be able to alter the form items' render arrays, but that would be the only way to change the HTML output of a form element.
D7 render array documentation: http://drupal.org/node/930760
The Examples module has a lot of good examples of render arrays: http://drupal.org/project/examples
Render arrays
Much thanks for the reference. This wasn't as trivial a change as I originally had hoped, but looks like a concept I need to better grasp anyhow.
Yeah, form-related stuff is
Yeah, form-related stuff is pretty deeply rooted in Drupal Core and not always easy to get at. It might be easier to use jQuery to hide the Drupal output of the "required" indicator and add in your custom indicator.