Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6939741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:39:39+00:00 2026-05-27T12:39:39+00:00

On my Drupal website I’ve got something like this: <div class=form-item form-type-textfield item-1> <div

  • 0

On my Drupal website I’ve got something like this:

<div class="form-item form-type-textfield item-1">
<div class="form-item form-type-textfield item-2">
<div class="form-item form-type-textfield item-3">
<div class="form-item form-type-textfield item-4">
...

Is there any way to get it like this

<div class="form-item form-type-textfield item-1 added-class">

or

<div class="wrapped-class">
   <div class="form-item form-type-textfield item-1">
</div>

So, to add a class to an item or wrap one around it. I played around with the hook_preprocess, but that didn’t work out.

A hook_form_alter isn’t the solution either, since you have to do it for each form… The div-class appears on multiple pages, so I would like to catch the statement with one code-snippet.
Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:39:40+00:00Added an answer on May 27, 2026 at 12:39 pm

    I’m surprised Drupal hasn’t ‘farmed out’ this functionality but if you look at the theme_form_element() function you can see the classes are statically set.

    The only way I can think to do what you want in code is to use a theme override for that function:

    function mytheme_form_element($variables) {
    
    }
    

    In that function you’ll need to place the entire code from the theme_form_element function (seems like overkill I know but I can’t think of a better way), and add your new class to the $attributes['class'] array:

    $attributes['class'] = array('form-item', 'my-other-class');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this website iloveforwards.com created using drupal. I would like to have a
I've got a simple Drupal website set up and is nearing completion. This website
in a Drupal 7 with PathAuto website: In pathAuto settings I have something like
I have this drupal website that revolves around a document database. By design you
I am building a Drupal website and want to have a facebook like box
I'm upgrading a drupal website. There are thousands of users and it is using
I have a drupal website using taxonomy. Now google indexed the taxonomy paths like:
I'm working on a drupal website that has a different class for the tag
I have installed the Content Profile module on my Drupal 6 website. This module
I've implemented a Drupal website. My customer wants to write javascript scripts (to produce

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.