octobercms/october · error · SystemException

Date dimensions cannot have fields.

Error message

Date dimensions cannot have fields.

What it means

Date dimensions (code exactly 'date', ReportDimension::CODE_DATE) are grouped by week/month/quarter/year directly from the dimension column by ReportDataQueryBuilder, so they cannot carry dimension fields. addDimensionField() checks isDate() and throws whenever a field is added to such a dimension.

Source

Thrown at modules/dashboard/classes/ReportDimension.php:152

            throw new SystemException('Unknown dimension type: ' . $dimensionType);
        }

        $this->code = $code;
        $this->databaseColumnName = $databaseColumnName;
        $this->displayName = $displayName;
        $this->dimensionType = $dimensionType;
        $this->labelColumnName = $labelColumnName;
    }

    /**
     * Adds a field to this dimension.
     * @param ReportDimensionField $field Specifies the field to add.
     * @return $this Returns the dimension object for method chaining.
     */
    public function addDimensionField(ReportDimensionField $field): ReportDimension
    {
        if ($this->isDate()) {
            throw new SystemException('Date dimensions cannot have fields.');
        }

        $this->dimensionFields[] = $field;
        return $this;
    }

    /**
     * Allows setting of custom field names for building queries that group data by week, month, quarter, and year intervals.
     * If the fields are not set, ReportDataQueryBuilder will use SQL functions to deduce interval start dates
     * from the dimension column value. This approach is less efficient than using indexed columns.
     * The names specified in the arguments must refer to columns containing start dates for the corresponding
     * intervals in the YYYY-MM-DD format. For example, the year column should contain values like 2023-01-01, 2024-01-01, etc.
     *
     * @param string $weekField The name of the column containing week start dates.
     * @param string $monthField The name of the column containing month start dates.
     * @param string $quarterField The name of the column containing quarter start dates.
     * @param string $yearField The name of the column containing year start dates.
     */

View on GitHub (pinned to b608633a7e)

Solutions

  1. Skip field registration for date dimensions: wrap addDimensionField() in if (!$dimension->isDate()) {...}
  2. If you truly need selectable sub-attributes, use a regular dimension code other than 'date' (e.g. 'status') and add fields to it instead
  3. Ensure config-driven dimension definitions do not include a 'fields' key for the 'date' dimension

Example fix

// before
foreach ($fields as $field) {
    $dateDimension->addDimensionField($field);
}

// after
foreach ($fields as $field) {
    if (!$dateDimension->isDate()) {
        $dateDimension->addDimensionField($field);
    }
}
Defensive patterns

Strategy: type-guard

Validate before calling

if ($dimension->getCode() === ReportDimension::CODE_DATE) {
    // date dimension: skip addDimensionField entirely
    return;
}
$dimension->addDimensionField($field);

Type guard

function dimensionSupportsFields(ReportDimension $dimension): bool
{
    return !$dimension->isDate();
}

Prevention

When it happens

Trigger: $dateDimension = new ReportDimension(ReportDimension::CODE_DATE, 'created_at', 'Date'); $dateDimension->addDimensionField(new ReportDimensionField('oc_field_status', 'Status')); — any addDimensionField() call on a dimension whose code === 'date'.

Common situations: Generic registration loops that iterate a config array and call addDimensionField() on every dimension, including the built-in 'date' dimension; reusing one field-registration routine for heterogeneous dimension lists.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/09d5873e62500972. Report an issue: GitHub.