octobercms/october · error · ApplicationException
backend::lang.model.missing_relation
Error message
backend::lang.model.missing_relation
What it means
During relation configuration in initRelationInternal, if the requested field is not a defined relation on the model (relationHasField fails), the localized relation.missing_relation/missing_definition error is thrown with the field name — the field isn't a relation or relationConfig lacks an entry for it.
Solutions
- Define the field in the controller's $relationConfig
- Ensure the model actually declares the relation method matching the field name
- Check the posted field name for typos
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/backend/behaviors/RelationController.php:392 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/08d588e1af3919f9.
Report an issue: GitHub.
Appendix: source
Thrown at modules/backend/behaviors/RelationController.php:392
// Configuration details
if (!$this->relationHasField($field)) {
throw new ApplicationException(Lang::get('backend::lang.relation.missing_definition', compact('field')));
}
$this->applyExtraConfig($field);
$this->alias = camel_case('relation ' . HtmlHelper::nameToId($field));
$this->config = $this->makeConfig($this->originalConfig->{$field}, $this->requiredRelationProperties);
$this->controller->relationExtendConfig($this->config, $this->field, $this->model);
$this->manageId = $this->getManageIdForField($field);
$this->pivotId = post('pivot_id');
$this->foreignId = post('foreign_id');
[$this->sessionKey, $this->relationSessionKey] = $this->getSessionKeysForField($field);
// Relationship details
[$nestedModel, $nestedField] = $this->makeNestedRelationModel($this->model, $this->config->valueFrom ?? $field);
if (!$nestedModel->hasRelation($nestedField)) {
throw new ApplicationException(Lang::get('backend::lang.model.missing_relation', ['class' => get_class($nestedModel), 'relation' => $nestedField]));
}
$this->relationParent = $nestedModel;
$this->relationName = $nestedField;
$this->relationType = $nestedModel->getRelationType($nestedField);
$this->relationObject = $nestedModel->{$nestedField}();
$this->relationModel = $this->relationObject instanceof HasOneOrMany
? $this->relationObject->make()
: $this->relationObject->getRelated();
$this->readOnly = $this->getConfig('readOnly');
$this->popupSize = $this->getConfig('popupSize', 950);
$this->externalToolbarBus = $this->getConfig('externalToolbarBus');
$this->eventTarget = $this->evalEventTarget();
$this->deferredBinding = $this->evalDeferredBinding();
$this->viewMode = $this->evalViewMode();
$this->manageMode = $this->evalManageMode();
$this->manageTitle = $this->evalManageTitle();View on GitHub (pinned to b608633a7e)