New to Craft CMS. We decided to make Craft headless and have an api fetch the data.
I have 5 (simple) sections that represent 5 pages and they all have some fields in them with some texts or images. So far so good.
Now, the cms is headless, so I added a controller to return the pages data (some texts and images). I used
Entry::find()->section('homepage')->one(); It returns an Entry Object, but the field's values are nowhere to be found.
Ex: In the cms, I have a hero field that contains a text and an image, but for the love of god I can't get the values of them using the query builder...
When I print the result of the query, I see the field names in the Entry object, but they are all NULL. Yes, my homepage entry in the cms is filled with texts and images for those fields...
[_behaviors:yii\base\Component:private] => Array ( [customFields] => craft\behaviors\CustomFieldBehavior Object ( [hero] => [titre] => [description] => [fullWidthCTA] => [...] ) )
I also tried
Entry::find()->section('homepage')->one()->getFieldValue('hero') but same problem...
If it's not clear enough, just let me know and I'll post an update in the morning.