0

I am trying to render three dropdown boxes to be on the same line using a tpl file. Here is the snippit of code I am trying to work with:

$form_stuff = array();
$form_stuff[]=$form['field_list_1'];
$form_stuff[]=$form['field_list_2']; 
$form_stuff[]=$form['field_list_3'];
print drupal_render($form_stuff);

I have also tried:

print drupal_render($form['field_list_1'] . $form['field_list_2'] . $form['field_list_3']);

Both will render each field element on a separate line.

This gets me a little closer but the dropdown renders on top of the label. It there a way to insert a <br> after the label renders or some sort of style=display:block?

print '<table><tr>';
print '<td>' . drupal_render($form['field_list_1']) . '</td>';
print '<td>' . drupal_render($form['field_list_2']) . '</td>';
print '<td>' . drupal_render($form['field_list_3']) . '</td>';
print '</tr></table>';

Thanks

1 Answer 1

0

In this, there is nothing to do with the coding part. When we add a field it adds lot of wrapper div tags around it. And div tags has the by default property to take the next line in the page.

Just write some css for these divs.

<style>
    div.class1(display:inline-block;width:150px;float:left) 
    div.class2(display:inline-block;width:150px;float:left) 
    div.class3(display:inline-block;width:150px;float:left) 
</style>

Hope it will work for you.

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.