CMS Drupal Mastering Development

How to embed HTML and CSS in a custom form element?

This worked in Drupal 7 but isn’t in Drupal 8.

$form['covid-19'] = array(
    '#markup' => '<div style="border: 2px solid red;padding:10px;margin-bottom:10px;"><strong>Due to the COVID-19 situation, we will only be purchasing e-books and e-audiobooks at this time.</strong> You are welcome to enter your information for print books, DVDs, or CDs, and they will be purchased when the libraries re-open.  Inter-library Loans [loans from outside Yavapai County] are suspended for now.</div>',

I want the div with style info to stay intact so I can just comment it out when the crisis is over. Then I want to leave it there as a placeholder ready for the next crisis.

In this example, the strong tag makes it through but the div does not.

I also tried setting the div info as a #prefix and #suffix but that didn’t work either.

Is there a way to do this?

Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *