octobercms/october · error · ApplicationException
Model ':class' does not contain a definition for…
Error message
Model ':class' does not contain a definition for ':relation'.
What it means
Thrown by resolveModelAttribute when the underlying form field's model resolution fails — the model class bound to the form widget has no relation (or nested attribute path) definition matching the requested name. It wraps the low-level exception into an ApplicationException with a localized message naming the class and relation. Consumers are getRelationModel, getRelationObject, getRelationType and isRelationTypeSingular, so any widget using them (e.g. record finder, relation manager) triggers this when its valueFrom/fieldName references an undefined relation.
Solutions
- Add the missing relation method (e.g. public function myRelation()) to the model class named in the message
- Correct the field name / valueFrom configuration in the form field YAML so it points to a relation that actually exists on the model
- If targeting a nested attribute, verify each segment of the dotted path resolves on the corresponding model
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at modules/backend/traits/FormModelWidget.php:30 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/13c1d6d72113951f.
Report an issue: GitHub.
Appendix: source
Thrown at modules/backend/traits/FormModelWidget.php:30
* @package october\backend
* @author Alexey Bobkov, Samuel Georges
*/
trait FormModelWidget
{
/**
* Returns the final model and attribute name of
* a nested HTML array attribute.
* Eg: [$model, $attribute] = $this->resolveModelAttribute($this->valueFrom);
* @param string $attribute.
* @return array
*/
public function resolveModelAttribute($attribute)
{
try {
return $this->formField->resolveModelAttribute($this->model, $attribute);
}
catch (Exception $ex) {
throw new ApplicationException(Lang::get('backend::lang.model.missing_relation', [
'class' => get_class($this->model),
'relation' => $attribute
]));
}
}
/**
* nearestModelAttribute
*/
public function nearestModelAttribute($attribute)
{
return $this->formField->nearestModelAttribute($this->model, $attribute);
}
/**
* Returns the model of a relation type,
* supports nesting via HTML array.
* @return RelationView on GitHub (pinned to b608633a7e)