RecordFinder fails to recognize parent_id field in models using NestedTree trait
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with the RecordFinder form widget and the model's NestedTree trait, then reproduce the reported parent_id validation error using a model with the listed tree fields and relationships. Done means RecordFinder accepts parent_id and allows selecting a parent record without requiring the Dropdown workaround.
Written by the indexing model from the issue text.
Description
Discussed in https://github.com/orgs/wintercms/discussions/1339
Originally posted by fleixweb April 18, 2025
Description
When using the RecordFinder form widget with a model that implements the NestedTree trait, the system incorrectly reports that the 'parent_id' field does not exist in the model, even though the field is properly defined in the database table and included in the model's $fillable array.
Steps to Reproduce
- Create a model that uses the NestedTree trait (e.g., ProductCategory)
- Add the necessary database fields (parent_id, nest_left, nest_right, nest_depth)
- Define parent and children relationships in the model
- Configure a form with a RecordFinder field type to select parent_id
- Attempt to create or edit a record
Expected Behavior
The RecordFinder should properly recognize the parent_id field and allow selection of a parent record.
Actual Behavior
The system displays an error: "Model '[Namespace][ModelName]' does not contain 'parent_id'."
Workaround
Replacing the RecordFinder with a Dropdown field type and implementing a getParentIdOptions() method in the model resolves the issue.
Technical Details
Winter CMS version: [Winter CMS 1.2.0]
PHP version: [PHP 8.2.26]
Database: MySQL [MySQL 8.0.40]
Suggested Fix
Modify the RecordFinder component to properly recognize and handle the parent_id field when used with the NestedTree trait. This would allow developers to use both features together without conflict.
Additional Context
This issue specifically occurs at the intersection of two Winter CMS features: the RecordFinder form widget and the NestedTree trait. Both work fine independently, but fail when used together to manage hierarchical relationships within the same model.
- Dominant language
- PHP
- Stars
- 1.5k
- Forks
- 246
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wintercms/winter
-
needs review
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
low priority needs pr
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
vite:watch writes an unreachable dev-server URL (http://[::]:5173) to the hot file on IPv6 hosts Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in wintercms/winter
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·