An editor adds a CMS Block component to a page in the Hyvä CMS editor and opens the dropdown to choose a block. The list never appears. It is the same on every page and in every block, for every admin user, and it was working last month.
In the browser console there is an Alpine expression error that ends in “Unexpected identifier”. Nothing is written to the Magento logs, because nothing failed on the server.
We traced this on a store running hyva-themes/commerce-module-cms 1.2.2. The cause was one CMS block, out of several hundred, whose title contained a double quote.
If this problem is costing you orders or staff time, our senior Magento and Hyvä team can help you debug it and deploy a fix safely.
Contact us →
Why it happens
The block picker is rendered by the editor’s searchable_select field type. Its template writes the list of options into an Alpine x-data attribute as JSON:
options: <?= $escaper->escapeHtml(json_encode($options)) ?>
Two details combine badly here.
- The labels are already escaped. The source model that builds the list of CMS blocks (
Hyva\CmsBase\Model\Config\Source\CmsBlocks) runs every label throughescapeHtml()before handing it over. A title such asFooter "Help" Linksarrives in the template asFooter "Help" Links. - **
escapeHtml()does not double-encode.** When the template escapes the JSON, the existing"is left as it is. Inside an HTML attribute the browser decodes it back to a plain".
The result is a JSON string with a bare double quote in the middle of a value. The string ends early, the rest of the title is read as JavaScript, and the whole x-data expression fails. Alpine never initializes the component, so the picker has no options at all, including the hundreds of blocks with harmless titles.
1. Confirm it
Look for block titles that contain a double quote:
SELECT block_id, title, identifier
FROM cms_block
WHERE title LIKE '%"%';
If the query returns a row and your picker is empty, you have found it. You can confirm on staging by renaming that block and reloading the editor.
2. The workaround that needs no code
Rename the block. Replace the double quotes in the title with single quotes, or remove them, and the picker works again at once. The title of a CMS block is only a label in the admin, so nothing on the storefront changes.
This is a reasonable stopgap, but it does not last. Sooner or later someone names a block 12" Banner or pastes a quoted phrase into a title, and the picker is empty again with no obvious connection to what they did.
If this problem is costing you orders or staff time, our senior Magento and Hyvä team can help you debug it and deploy a fix safely.
Contact us →
3. Patch the template
The durable fix is a composer patch to src/liveview-editor/view/adminhtml/templates/liveview/field-types/searchable_select.phtml. It decodes the labels back to plain text, which is safe because the template renders them through x-text, and it encodes the JSON with the attribute escaper.
--- a/src/liveview-editor/view/adminhtml/templates/liveview/field-types/searchable_select.phtml
+++ b/src/liveview-editor/view/adminhtml/templates/liveview/field-types/searchable_select.phtml
@@ near the top, after $options is read @@
$options = (array) $block->getData('options');
+$jsOptions = array_map(
+ static function ($option) {
+ if (is_array($option) && isset($option['label']) && (is_scalar($option['label']) || $option['label'] instanceof \Stringable)) {
+ $option['label'] = html_entity_decode((string) $option['label'], ENT_QUOTES | ENT_HTML5, 'UTF-8');
+ }
+ return $option;
+ },
+ $options
+);
@@ inside the x-data attribute @@
- options: <?= $escaper->escapeHtml(json_encode($options)) ?>
+ options: <?= $escaper->escapeHtmlAttr((string) json_encode($jsOptions, JSON_INVALID_UTF8_SUBSTITUTE)) ?>
The block above shows the change. Generate the actual patch file with diff -u against the version you have installed, then register it:
"extra": {
"patches": {
"hyva-themes/commerce-module-cms": {
"CMS Block picker loads when a block title contains a double quote": "patches/hyva-cms-searchable-select.patch"
}
}
}
escapeHtmlAttr() encodes every character that could end the attribute or the string, so the JSON survives the trip through the HTML parser whatever the titles contain. JSON_INVALID_UTF8_SUBSTITUTE keeps one badly encoded title from turning the whole list into false.
4. Verify
composer install
bin/magento cache:flush
Reload the Hyvä CMS editor and open the picker. Every block should be listed, and the one with the double quote should show its title exactly as it reads in the CMS Blocks grid. Select it, save the page and check that the storefront renders the block.
Notes before you ship this
- This is not fixed by upgrading yet. As of December 2026 the newest release, 1.3.3, still writes the options with
escapeHtml(json_encode(...))and still escapes the labels in the source model. - The patch fixes the field type, so every
searchable_selectfield benefits, not only the CMS Block picker. - The general rule: data written into an HTML attribute as JSON needs the attribute escaper, and it should be escaped once, at the point of output. Escaping in the source model and again in the template works until a value contains the one character the first pass had already converted.