0

I am trying to recreate the following paragraph in a custom Drupal form.

enter image description here

How do you create multiple selects in a single paragraph?

2
  • 1
    What about wrapping them in a field prefix/suffix div... could that maybe help? Commented Apr 25, 2017 at 6:17
  • @longboardnode: That's an excellent suggestion and I will investigate it BUT some of the sentences can and do have more than one dropdown list item
    – sisko
    Commented Apr 25, 2017 at 10:21

1 Answer 1

1

You can try a combination of wrapping the whole form in a div, so:

form['#prefix]='<div class="form-wrapper">';
  $form['markup1'] = array(
    '#type' => 'markup',
    '#markup' => 'Hello this is a pulldown '
  );
  $form['pulldown1'] = array(
    '#type' => 'select',
    '#required' => TRUE,
    '#options' => array('option1', 'option2', 'option3'),
  );
  $form['markup2'] = array(
    '#type' => 'markup',
    '#markup' => ' and this is another pulldown '
  );
  $form['pulldown2'] = array(
    '#type' => 'select',
    '#required' => TRUE,
    '#options' => array('option4', 'option5', 'option6')
  );
form['#suffix]='</div>';

then use theme_form_element to remove the field wrapper divs that Drupal injects automatically around each field, see this post. Once these individual divs around each pulldown are removed then the pulldowns will render inline with the markup.

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.