You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# /site/models/default.php
<?php
use Kirby\Cms\Page;
class DefaultPage extends Page
{
public function myCustomMethod()
{
var_dump($this->inventory());
}
}
There is also Page::inventory() as core method which is why you cannot use it as field name (or if you need to access it via $page->content()->get('inventory').
The problem is that the method is marked as internal (which is right as it shouldn't be used programatically by non-expert user), but that's also why it's hidden in the docs reference. Which then of course makes it hard for you to know that it's a reserved name.
distantnative
changed the title
Field inventory collides in model with $user method
Hidden model methods: how to know that they are reserved names?
Aug 20, 2024
Description
Hi all!
I think I ran into a bug with a field named
inventory
and accessing it in a page model.The output is:
Expected behavior
Access to the field
inventory
, instead I think I get the result of$users->inventory()
^, so a list of filesAdditional context
Maybe this is expected behaviour, but as far as I could find in the docs, it should only be part of
Kirby\Cms\User
?Thank you for all the hard work and the wonderful CMS!
To reproduce
Your setup
K 4.3.0 Plainkit
The text was updated successfully, but these errors were encountered: