octobercms/october · error · Error
Error parsing Inspector field values. ${err}
Error message
Error parsing Inspector field values. ${err} What it means
The October CMS `{% put %}` tag has two modes: direct assignment (`{% put a, b = expr1, expr2 %}`) and block capture. In direct-assignment mode, PutTokenParser counts the target names from parseAssignmentExpression and the values from parseMultitargetExpression and throws this SyntaxError when the counts differ — assignment is all-or-nothing per side.
Source
Thrown at modules/backend/assets/foundation/controls/inspector/inspector.datainteraction.js:58
if (propertyInfo.property.toLowerCase() == lowerCaseCode) {
return propertyInfo.property
}
}
return code
}
DataInteraction.prototype.loadValues = function(configuration) {
var valuesField = this.getElementValuesInput()
if (valuesField) {
var valuesStr = $.trim(valuesField.value)
try {
return valuesStr.length === 0 ? {} : JSON.parse(valuesStr)
}
catch (err) {
throw new Error('Error parsing Inspector field values. ' + err)
}
}
var values = {},
attributes = this.element.attributes
for (var i=0, len = attributes.length; i < len; i++) {
var attribute = attributes[i],
matches = []
if (matches = attribute.name.match(/^data-property-(.*)$/)) {
// Important - values contained in data-property-xxx attributes are
// considered strings and never parsed with JSON. The use of the
// data-property-xxx attributes is very limited - they're only
// used in Pages for creating snippets from partials, where properties
// are created with a table UI widget, which doesn't allow creating
// properties of any complex types.
//View on GitHub (pinned to b608633a7e)
Solutions
- Make the number of values match the number of names exactly, e.g. `{% put a, b = 1, 2 %}`.
- If you only need one of the values, use separate `{% put a = 1 %}` statements.
- For computed/multiple outputs, use a single array value: `{% put pair = [1, 2] %}`.
Example fix
// before
{% put listItems, total = 1, 2, 3 %}
// after
{% put listItems, total = [1, 2, 3], 3 %} Defensive patterns
Strategy: try-catch
Validate before calling
// Author-time check: counts on both sides of `=` must match
$src = '{% put a, b = 1, 2, 3 %}';
if (preg_match('/{%-?\s*put\s+([^=]+?)\s*=\s*([^%]+?)\s*%-?}/', $src, $m)) {
$names = preg_split('/\s*,\s*/', trim($m[1]));
$values = preg_split('/\s*,\s*/', trim($m[2]));
if (count($names) !== count($values)) {
throw new RuntimeException('put targets and values count mismatch');
}
} Try / catch
try {
$twig->load($template);
} catch (Twig\Error\SyntaxError $e) {
if (str_contains($e->getMessage(), 'same number of variables')) {
// fix the {% put %} line named in the error
}
throw $e;
} Prevention
- Keep one name and one value per {% put %} unless pairing lists deliberately.
- Re-count both sides whenever you add a variable to a put tag.
- Prefer separate put statements or an array value for grouped data.
When it happens
Trigger: Writing `{% put a, b = 1, 2, 3 %}` (3 values for 2 names) or `{% put a = 1, 2 %}` (2 values for 1 name). It fires during Twig parsing, before any evaluation.
Common situations: Adding another variable to one side of an existing `{% put %}` line and forgetting the other; refactoring placeholder assignments; copying set-style syntax where counts can differ.
Related errors
- Error parsing Inspector configuration. ${err}
- ${errorMessage} Property: ${this.propertyDefinition.property
- Error parsing the ${name} attribute value. ${e}
- Error parsing the data-chart-options attribute value. ${e}
- The titleProperty property should be specified in the object
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/2c9fd5fef5a306cb.
Report an issue: GitHub.