How do I add a  after every field element on the node edit form? There are two approaches that have failed:


In the theme, add a theme hook for the node edit form.  Then, create a template file for the node edit form.  This won't work for my case, because the form is rendered in the template file with drupal_render_children, and therefore the contents of the form are not reachable within the template file--I need to add the divs in between the form elements.
Use hook_form_alter.  This won't work for my case, because you have to target a specific form item.  The users may, for example, add a new node field after I hand it off to them, and my existing hook_form_alter wouldn't have a way to catch it.


What I want to do is simple; in between every element on the node edit form, insert a &lt;div class="clearfix"&gt;&lt;/div&gt; to separate them.

Or, I could add the "clearfix" class to the existing div containers around the form elements.

Do we have a solution for either method?

[EDIT] Here is the solution using hook_form_alter():

&lt;?php
/**
 * Implements hook_form_alter()
 */
function mytheme_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if (preg_match('/node_form$/', $form_id)) {
    $language = $form['language']['#value'];
    foreach ($form_state['field'] as $field =&gt; $field_contents) {    
      $form[$field][$language]['#suffix'] = '&lt;div class="clearfix&gt;&lt;/div&gt;';
    }
  }
}
?&gt;
The easiest way is using hook_form_alter for each Field add #suffix =&gt; '&lt;div class="clearfix"&gt;&lt;/div&gt;" to the existing FAPI array for the Field. I would just hard code it per field.

If you need to you could make a for loop and walk through the FIELDs so you dont hardcode the fields by hand ... If you were more crazy you could use an #after_build function too on the $form or set 1 per Field element as needed if you run into problems.