I've got a Drupal 6 form API question which may or may not be possible, or a good idea.

Is it possible to have two input fields per label?

I'm familiar with this format:

$form['example_textfield'] = array(
'#type' => 'textfield',
'#title' => t('text here'),
'#size' => 30,
'#maxlength' => 32,
'#required' => TRUE,

As the way to make one label with one field, but is it possible to have one label and two input fields? and create something like: label: {input field} {input field}

If there is a way to do it, how would I get the two values into the DB table?

Is such an approach even a good idea? or should I stick to the single label/single input field method demoed above?

  • maybe this can help: drupal.org/node/46744
    – Codium
    Commented Jan 17, 2013 at 19:54
  • you can add a fieldset with your label and empty the labels of you input fields
    – Varshith
    Commented Jan 18, 2013 at 6:50

2 Answers 2


You cannot have a label for two form fields, as the label is output with HTML code similar to the following one.

<label for="edit-category">Category: <span class="form-required" title="This field is required.">*</span></label>

The attribute for accepts a single form element ID; you cannot use the following HTML, for example.

<label for="edit-category edit-recipients">Category/Recipients: <span class="form-required" title="This field is required.">*</span></label>

If you don't want to use a label for the second form element, you can simply use an empty string for the #title property.

As for saving those values in the database, a label is not used when saving the value of a form element, but it is used only on the user interface. The code for saving the content of a form element doesn't use the label value, but the identifier associated to the form element.
In your case, the form submission handler would get the value entered from the user for the $form['example_textfield'] element from $form_state['values']['example_textfield'] where in Drupal 5 would have used $form_values['example_textfield'].


I ended up using two field sets rather than try to get two input fields next to one label.

It's more work upfront, but possibly more stable/reliable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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