Drupal - Custom text/html in custom form module

What kind of entry (or #type) should I insert to get just an custom html/text block between fields or above them all?

Item element type provides a display-only form element with an optional title and description.

$form['help'] = [
  '#type' => 'item',
  '#title' => t('Block title'),
  '#markup' => t('Block content'),
];

You may also add arbitrary content to render arrays using the #markup render array key as follows.

$form['text']['#markup'] = t('Some text.');

#field_prefix #field_suffix and #description should do the trick. Here's more info about FormElement. I believe you can also set an element to type markup and then use #markup to create an element that's just HTML (see ya.teck's answer).

Tags:

Forms

8