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

FormsApiDrupalDrupal 7Drupal Forms

Forms Problem Overview


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?

Forms Solutions


Solution 1 - Forms

You can do this using #markup:

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIvo RenkemaView Question on Stackoverflow
Solution 1 - FormsCliveView Answer on Stackoverflow