octobercms/october · error · Error

Trying to get selected row without a popup reference.

Error message

Trying to get selected row without a popup reference.

What it means

The dashboard inspector-configurator fetches dropdown options over AJAX (via the handler named by the store's `onInspectableGetOptions` event) and requires the response's `options` property to be an array of `{ value, title }` items, which it converts into a value-to-title map. If the server handler returns `options` as an object/map, a string, or null (for example by returning `['one' => 'One']` keyed maps directly), Array.isArray fails and this Error is thrown client-side.

Source

Thrown at modules/backend/assets/foundation/controls/inspector/inspector.editor.objectlist.js:351

            return
        }

        value = $.trim(value)

        if (value.length === 0) {
            value = '[No title]'
            $.oc.foundation.element.addClass(selectedRow, 'disabled')
        }
        else {
            $.oc.foundation.element.removeClass(selectedRow, 'disabled')
        }

        selectedRow.firstChild.textContent = value
    }

    ObjectListEditor.prototype.getSelectedRow = function() {
        if (!this.popup) {
            throw new Error('Trying to get selected row without a popup reference.')
        }

        var rows = this.getTableBody().children

        for (var i = 0, len = rows.length; i < len; i++) {
            if ($.oc.foundation.element.hasClass(rows[i], 'active')) {
                return rows[i]
            }
        }

        return null
    }

    ObjectListEditor.prototype.createItem = function() {
        var selectedRow = this.getSelectedRow()

        if (selectedRow) {
            if (!this.validateKeyValue()) {

View on GitHub (pinned to b608633a7e)

Solutions

  1. Make the handler return `['options' => [...]]` where the inner value is a list of items with `value` and `title` keys.
  2. If your source data is a value=>title map, convert it: `foreach ($map as $value => $title) { $list[] = ['value' => $value, 'title' => $title]; } return ['options' => $list];`.
  3. Check the network tab for a non-200 or error response — an exception inside the handler also produces a missing/non-array `options`.

Example fix

// before
public function onInspectableGetOptions()
{
    return ['one' => 'One', 'two' => 'Two'];
}

// after
public function onInspectableGetOptions()
{
    $list = [];
    foreach (['one' => 'One', 'two' => 'Two'] as $value => $title) {
        $list[] = ['value' => $value, 'title' => $title];
    }
    return ['options' => $list];
}
Defensive patterns

Strategy: type-guard

Validate before calling

// Server-side: normalize any map into the required options array shape
public function onInspectableGetOptions()
{
    $map = $this->getMyOptions(); // ['one' => 'One', ...]
    $list = [];
    foreach ($map as $value => $title) {
        $list[] = ['value' => (string) $value, 'title' => $title];
    }
    return ['options' => $list];
}

Type guard

// Client-side guard around the response before using it
/**
 * @param {any} data
 * @returns {boolean}
 */
function isValidOptionsResponse(data) {
    return data != null
        && Array.isArray(data.options)
        && data.options.every(item => item != null && 'value' in item && 'title' in item);
}

Try / catch

try {
    const result = await this.requestOptions(/* ... */);
} catch (e) {
    if (/must return an array/.test(e.message)) {
    // inspect the handler response in the network tab; fix the PHP return shape
    }
}

Prevention

When it happens

Trigger: A custom `onInspectableGetOptions` handler returning a key=>title map instead of `['options' => [ ['value' => ..., 'title' => ...], ... ]]`; a handler that returns nothing (null) or an error page/HTML because it threw; the request being intercepted and reshaped by other JS.

Common situations: Porting old get*Options methods (which return `['value' => 'title']` maps, like Backend's InspectableContainer converts them) and forgetting the conversion; dashboard widgets implementing HasPropertyOptions::onInspectableGetOptions incorrectly; handlers crashing so the AJAX response has no options key.

Related errors


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