octobercms/october · error · ValidationException

Please enter a valid URL

Error message

Please enter a valid URL

What it means

ValidationException raised in the PageLookup widget's onInsertReference AJAX handler when the reference field is visible and enabled but the submitted form data contains an empty reference value (typically a URL). It signals that the user left the required reference/URL input blank while inserting the reference.

Solutions

  1. Enter the full URL in the reference field
  2. Select a different reference type if a static URL is not intended
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/cms/widgets/PageLookup.php:176 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at modules/cms/widgets/PageLookup.php:176

        $data = $widget->getSaveData();
        $type = array_pull($data, 'type', '');
        $reference = array_pull($data, 'reference', '');

        // Validate
        if (!$type) {
            throw new ValidationException(['type' => 'Missing type!']);
        }

        if (!$widget->getField('cms_page')->hidden && !isset($data['cms_page'])) {
            throw new ValidationException(['cms_page' => __('Please select a CMS page')]);
        }

        if (!$widget->getField('reference')->hidden && !$widget->getField('reference')->disabled && !$reference) {
            throw new ValidationException(['reference' => __('Please select a page reference')]);
        }

        if ($type === 'url' && (!isset($data['url']) || !PageLookupItem::isValidUrl($data['url']))) {
            throw new ValidationException(['reference' => __('Please enter a valid URL')]);
        }

        // Determine reference title
        $model = $widget->model;
        $model->type = $type;
        $model->reference = $reference;

        // Split params and data
        $params = $data;
        if ($title = $model->getReferenceLabel()) {
            $params['title'] = $title;

            if ($this->shouldIncludeTitle()) {
                $data['title'] = $title;
            }
        }

        return [

View on GitHub (pinned to b608633a7e)