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:
- How to add class to content field link in Drupal 8 / 9
- How to Add target attribute to form and submit buttons in Drupal 8 / 9
- How to change canonical URL in drupal 8 / 9
- How to display in twig node creation date yesterday / today format in drupal 8 / 9
- Error: Class ‘DOMDocument’ not found in Drupal\Component\Utility\Html::load() (line 286 of core/lib/Drupal/Component/Utility/Html.php)
730