1

I want to remove the extra divs that get added like in the following example (user-register-form):

<div class="field-type-text field-name-field-phone-number field-widget-text-textfield form-wrapper" id="edit-profile-parent-field-phone-number">
  <div id="profile-parent-field-phone-number-add-more-wrapper">
    <div class="form-item form-type-textfield form-item-profile-parent-field-phone-number-und-0-value">

    <label for="edit-profile-parent-field-phone-number-und-0-value">phone number <span class="form-required" title="This field is required.">*</span></label>
    <input class="text-full form-text required" type="text" id="edit-profile-parent-field-phone-number-und-0-value" name="profile_parent[field_phone_number][und][0][value]" value="" size="60" maxlength="255" />
    </div>
  </div>
</div>

I already did YOUR_THEME_form and YOUR_THEME_form_element in template.php to get rid of extra divs. But this only works for the standard fields of a form it seems.

I am using profile2 and profile2_regpath modules and it seems as if they add themselves extra divs for the fields that are specific to the profile fields. But I can't figure out how to overwrite this behavior.

Any help or hint appreciated.

And just in case it is already written somewhere: I used the search function and could only find the standard solution for normal fields. Nothing specific to profile2 module.

Oh and some details: I'm using Drupal 7. If anything else is needed, please tell me.

Thank you, best regards.

1

You can use a theme_field override to adjust the field markup.

e.g, for body field on article content type:

  1. Copy theme_field to template.php
  2. Rename function to THEMENAME_field__body__article($variables)
  3. Clear theme registry cache
  4. Modify theme function markup to suit.

Note, the theme function naming convention required the "field_" prefix on field names, e.g THEMENAME_field__field_example__article()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.