Community & Support

How can I force form field label to display inline

I am using Zen theme. I have a problem of putting my form fields inline even though I have configured them this way. I want to be able to do this for the registration form and also node forms. Any suggestions

Comments

What do you mean by "even

What do you mean by "even though I have configured them this way"? Have you add css rules to style.css to make the form fields inline? And by "form fields inline" do you mean label and input field on same line.

yes ...

.... I mean label and input field on same line.

I added the following to the

I added the following to the themes styles.css file and it should help you get going

.form-item label {
  display:inline;
}

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

It is only a starting point since the second line only applies to text fields and you may want to apply other input types.

Sad to say it never worked

Sad to say it never worked

It works

Hi,

Thanks for the CSS tips - it works fine - and yes, it is a starting point. I further worked on it and now i have this,

.form-item label {
display: block; /* block float the labels to left column, set a width */
float: left;
width: 150px;
padding: 1px;
margin: 5px 0 0; /* set top margin same as form input - textarea etc. elements */
text-align: right;

}

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

This works fine for me.

Vinay Yadav
PHP / Drupal Developer
http://www.vinayras.com

www.eDrupal.com - Indian Drupal Community

Vinay Yadav
PHP / Drupal Developer
http://www.vinayras.com

subscribe

subscribe

D

inline display in drupal form element

Append template.php

Add
function YOURTHEMENAME_form_element($element, $value) {
$output = ''."\n";
$required = !empty($element['#required']) ? '*' : '';

if (!empty(
$element['#title'])) {
$title = "".$element['#title']."";
if (!empty($element['#id'])) {
$output .= ' '. t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."\n";
}
else {
$output .= ' '. t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."\n";
}
}

$output .= " $value

< ajay /table>\n";

if (!empty($element['#description'])) {
$output .= '
'. $element['#description'] ."\n";
}

$output .= "\n";

return
$output;
}

Hope this will show you a tabulated form
Note : Remove all "ajay" text before use.
Kind regards
Ajay singh rathore
Netlink

Kind regards
Ajay Singh Rathore
Cisin,India

Sub

Sub