1

I've been using globals many times but this is my first time encounter with such problem. Let's go from the bottom. I have two global sets with handles tax and company. The Tax set have only one plain text field taxRate which can be accessed like documentation says {{ tax.taxRate }}.

The Company set have more plain text fields and one table field. Odd thing happens when I try to access any plain text field the same way. Example: {{ company.businessName }}.

I've tried to see what I get outputted using dump() function of that field and the output is quiet broader than the dump output of {{ tax.taxRate }}.

{{ dump(tax.taxRate) }}` -> string(2) "20"

{{ dump(company.businessName) }}` -> object(Craft\ElementCriteriaModel)#942 (17) {
["strictAttributes":protected]=>
bool(false)
["_elementType":"Craft\ElementCriteriaModel":private]=>
object(Craft\EntryElementType)#372 (7) {
["componentType":protected]=>
string(11) "ElementType"
["_sourcesByContext":"Craft\BaseElementType":private]=>
NULL
["_classHandle":"Craft\BaseComponentType":private]=>
NULL ... and another dozens lines of it

I can access it using craft.globals.getSetByHandle('company') but I don't understand why I'm getting object returned in the set Company and string returned in the set Tax using the same fetch approach?

1

Well, when I went properly through the output of {{ dump(company.businessName) }} I found out right from the start that it is element criteria model of entry type. That led me to check for the handle company that could exists twice in system.

I found section with the handle company. So two identical handles in system were causing my problem. But on the first place, how could Craft let me save the global set with the handle that already existed in system even if they are different type of element criteria model and Craft would throw that string conversion error anyway?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.