Hi,
something very strange is happening.
I use virtual fields often. I am familiar with them.
However, there is a specific Entity in my code, where I cannot retrieve the virtual fields.
Does anyone know what could be happening?
Important detail, if I create some function in the entity I get the error:
“all to undefined method Cake\ORM\Entity::test()”
It’s like nothing I did in the entity had any effect.
Here’s the entity code:
class Receita extends Entity
{
protected function teste(){
return 'ok';
}
protected function _getField(){
return 'test';
}
}
Below how I retrieve the fields and call the function
Hi @KevinPfeifer ,
Thanks for your help.
But I think it’s not the problem.
I set the function visibility to public, but the error still persists. And theoretically the visibility would not affect the virtual field as well, and I would be able to access it. The problem is that I can only access database attributes, virtual fields and entity functions are not accessible.
The strange thing is that it’s only for that specific “Receita” type. The other entity types work normally, as per the cakePHP documentation.
I’m using nameing convention _get<CamelCasedProperty>, and I know that functions are not virtual fields, but I can’t access both.
The code
class Receita extends Entity
{
public function teste(){
return 'ok';
}
protected function _getField(){
return 'test';
}
}