How to add a html field to a form in drupal 8 & 9

4.5
(2)

Code snippet that can be used to add a html field to a form in drupal 8 & 9.

$form['field_name'] = [ '#markup' => '<h2>' . $node->get('field_name')->getString() . '$</h2>', ];

$form['field_age'] = [ '#markup' => '<h4>' . $node->get('field_age')->getString() . '$</h4>', ];

Similar Posts:

571

How useful was this post?

Click on a star to rate it!

Average rating 4.5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

Scroll to Top