I already have some virtual fields working on my application, but this one is busting my mind.
So I have the entity SubactivitySlots, with the following code:
protected $_virtual = [
'slots_text',
];
and
protected function _getSlotsText(){
return "test";
}
When I run the query:
debug($this->SubactivitySlots->find('all')->first());
It returns me the following structure (tried with both first and toArray()
object(App\Model\Entity\SubactivitySlot) {
'id' => (int) 1,
'name' => 'MAIN',
'description' => '-',
'activity_id' => (int) 1,
'subactivity_min' => (int) 1,
'subactivity_max' => (int) 1,
'position' => (int) 1,
'institution_id' => (int) 1,
'deleted' => (int) 0,
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [
(int) 0 => 'slots_text'
],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'SubactivitySlots'
}
Any clue of what might be wrong? I'm spent a lot of time trying to discover and can't find out. The strangest thing is that i'm using virtual fields on another entities and it's working.
Thanks