Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using route key other than 'id' not working #53

Closed
kmcluckie opened this issue Jul 7, 2021 · 4 comments
Closed

Using route key other than 'id' not working #53

kmcluckie opened this issue Jul 7, 2021 · 4 comments

Comments

@kmcluckie
Copy link

Description

I have an existing model that uses the Spatie/Sluggable package, and uses the getRouteKeyName() method to set a custom route key: 'slug'. The listing page of Runway uses the 'id' field to generate the edit link (eg. http://localhost/cp/runway/product/1), but the Resource Controller edit method uses the routeKey() method in retrieving the model record. So it is trying to find a record whose slug is '1'. This results in an "Attempt to read property "name" on null" error, since the record cannot be retrieved.

Steps to reproduce

  1. Add getRouteKeyName() method to your model returning a key name other than 'id' (eg. 'slug')
  2. Navigate to a Runway index page and try to edit a record

Environment

Statamic 3.1.27 Solo
Laravel 8.42.1
PHP 8.0.7
doublethreedigital/runway 2.1.1

@duncanmcclean
Copy link
Member

Ah whoops, I'll fix this today. Sorry!

@kmcluckie
Copy link
Author

Thanks very much. Didn't know where to put this given the bug report template structure, but I only just discovered this addon yesterday, and I'm really liking it. Thanks for the work!

@duncanmcclean
Copy link
Member

No worries! 🙂

@duncanmcclean
Copy link
Member

duncanmcclean commented Jul 7, 2021

Closed by f7c52cb & released in v2.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants