Sorry, we don't support your browser.  Install a modern browser

Warn when field name is the same as common Kirby methods#578

I recently ran into an issue when I made a field named image and used $page->image() to access it.

Only later, it turned out that image() is a native Kirby method returning the first image. When there were multiple images uploaded to the page, the problem became apparent, as the first image got returned instead of the image specified in the page’s field.

I had similar issues with naming collisions before. They are always quite annoying, as everything seems to work without errors, so debugging it is hard.

Perhaps Kirby could give some kind of warning (only in development mode) when a field name might collide with a native Kirby method? This would definitely improxe the developer experience for me.

8 months ago
S

Yes, a warning would be great!

2 days ago