Skip to main content
Key2Goal

Main navigation

  • Home
  • About Us
  • Contact us
  • Glossary
  • Privacy Policy
User account menu
  • Log in

Breadcrumb

  1. Home

Drupal 8 form Markup Element alternative

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.

  • Log in to post comments

Comments

Article category

  • Drupal
  • Wordpress
  • Java
  • Javascipt
  • HTML
  • CSS
  • IOS
  • Android
  • PHP
  • MySQL
  • Other
  • Command line
  • NodeJs
  • Drupal 8
  • Drupal 7
  • GIT
  • DevOps
  • Python
  • Xampp
  • Server
  • Artificial intelligence
  • AppScript

Recent content

  • Differences Between Bootstrap 3 & Bootstrap 4
    2 days ago
  • About Us
    2 days 18 hours ago
  • Privacy Policy
    2 days 20 hours ago
  • Create a Virtual Host on Xampp in 5 steps
    1 month 1 week ago
  • How to setup Multisite in drupal 9
    7 months 3 weeks ago
  • How to creating a FOR loop and a WHILE loop in JavaScript
    7 months 3 weeks ago
  • Calculator program HTML & PHP
    7 months 3 weeks ago
  • Algothrim to create a web application
    7 months 3 weeks ago
  • 10 Git Useful Commands for Every Developer
    7 months 3 weeks ago
  • Top 10 useful commands for GIT with example
    7 months 3 weeks ago
© Copyright 2017 - 2026 key2Goal. All Rights Reserved