1

I have this:

$form['rate_the_room']['room_rating'] = array(
  '#type' => 'radios',
  '#title' => 'How would you rate the room you stayed in?',
  '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5),
  '#default_value' => isset($values['room_rating']) ? $values['room_rating'] : NULL,
);

$form['next'] = array(
  '#type' => 'submit',
  '#value' => t('Next')
);
return $form;

This will produce a radio button block where you can select the rating for a room and then a submit button right after it. I want to be able to add a block of text inbetween these two elements. That block should be:

<div id="test">Hello</div>

Is this possible or would I have to somehow make it part of the actual fields?

  • 2
    Do you mean like this or something more complicated? – Clive Oct 14 '14 at 14:01
4

To add plain text to forms, you use #markup- see the Form API.

$form['rate_the_room']['hello'] = array(
  '#markup' => '<div id="test">Hello</div>',
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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