Adding text (just text!) to a form in Drupal 7

Ivo Renkema picture Ivo Renkema · Dec 6, 2011 · Viewed 38.8k times · Source

OK, I finally figured out how to add (or edit) form controls through the form API in Drupal.

But now, I would like to add text to a form. Not a <textarea>, and not a <textfield>; both of which can be edited by the user. I would like to add <p>static text</p>, written by me, to be read by the user.

How would one do that?

Answer

Clive picture Clive · Dec 6, 2011

You can do this using #markup:

$form['some_text'] = array(
  '#markup' => '<p>Some text</p>'
);