Fetch fields from a selected structure

If I dumb the $selectedField it returns nothing.

Then you now have to find out why. Check the values you store in your select field in the content files. Does it contain anything. Are there any differences in spelling in what is saved from the select field and how it is stored in the structure field entries etc.

Have a break first and then get back to it with a fresh mind.

Yes, I know the values are there, you can see it in the structure field dump. The problem I think is the filter, it doesn’t return anything.

I will check it again later.

Yes, the structure field is there, but check what the select field actually saves in your text file. Does it really store the value “Amazon Banner” or “Google Ad” exactly like this or does it store something else?

Ok, I did a quick test and the problem seems to be that you have to use the value() field method, otherwise it doesn’t return a result:

$adSelected = $page->ad()->value();

I can never remember when to use value() and when not, that’s a bit annoying. Maybe get used to always using it just in case, whenever we are dealing with strings.

1 Like

That works!

Thank you Sonja.