formsapidrupaldrupal-7drupal-forms

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


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?


Solution

  • You can do this using #markup:

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