Share icon

Hi Guys, today topic is markup element of form api drupal 8. As we know the form api is describe the how the actually it can we used under development process, but recetry I found that markup element is missing form drupal 8 form api, so what if we need to display custom html with custom form then we can use the alternative as i show below.

In Drupal 7 there is specfied element in form api for markup, many of you used this before 

$form['contact_information'] = array(
  '#markup' => "<p>this is markup text</p>",
);

In Drupal 8, you can use the below code as alternative to markup

$form['markup_demo'] = [
  '#type' => 'item',
  '#title' => '',
  '#markup' => '<h1>This is markup ...</h1>',
];

so, yes you can use this if you need markup in custom form, hopes this help.

Add new comment

Restricted HTML