Select option list, including html tags

I’m creating a Block Edit Select Option as such:

$options = array(
	'' => t('None'),
	'h1' => t('<h1>'),
	'h2' => t('<h2>'),
	'h3' => t('<h3>'),
	'h4' => t('<h4>'),
	'h5' => t('<h5>'),
	'h6' => t('<h6>'),
	'b' => t('<b>'),
	'small' => t('<small>')
echo $form->label('includeTitleFormat', t('Title Format'));
echo $form->select('includeTitleFormat', $options, $controller->includeTitleFormat, ["id" => "includeTitleFormat"]);

Under v9 the dropdown list populates with <h1>,<h2> etc, in v8 all the options are available but the visible text is blank as though the browser is rendering the tags. What gives between v8 and v9 that this happens differently?

Try 'h1' => h(t('<h1>')), to escape the html tags.

1 Like

@JohntheFish works a charm. Still wondering where along the lines this changed. Wanted to experiment with getting icons into the lists (not these lists in particular) but at this rate it doesn’t appear it’s going to work?!

A bootstrap dropdown is good for that kind of select with more complex items. Or you can use classes and before /after pseudo styles.
Maybe the change in behaviour was an ‘issue’ that got fixed.