Greetings,

Can anybody suggest how to properly output a form element with no BR tag after element label, so label and value will go on the same line. There was a problem with that in Drupal 4.6 .... It was not customizible - BR was hardcoded in form_element() function

Thanks.

Comments

nevets’s picture

While you can override theme_form_element, I see no generation of an HTML break and suspect it is more a question of css styling. If you look in drupal.css you will find

.form-item label {
  display: block;
  font-weight: bold;
}

which should be the source of the 'break'. If you override this in styles.css (for the theme you are using) with

.form-item label {
  display: inline;
}

This will get you started. For text fields you will want to add

.form-item .form-text {
  width: auto;
  display: inline;
}

First line overrides the setting of width to 100% in drupal.css, the second makes it inline.
You may find the space between the label and form element too small after you do this so you may want to change the rule for '.form-item label' to include a setting for margin-right.

ardas’s picture

Okay. Thanks. But what if I need to have several textfields with break and several without them within one theme?

I currently see only one solution - ovverride all theme_[form_element] functions to add one more bool parameter and patch them to insert BR depending on that parameter.

nevets’s picture

Each text field as both a form id and field id so you should be able to use those to restrict how the label shows up.

Also, I a pretty sure the theme function no longer inserts a break statement but replies on css rules.

ardas’s picture

Thanks a lot for your help.