Call to a member function getTemplateHelper() on string [solved]


#1

Silverstripe Version: 3.7.2

PHP Version: 7.2

Question:

Hi. I am having a problem when trying to edit an existing news article from /admin.

When clicking the edit-button (linking to for example https://www.mysite.com/admin/news/NewsPage/EditForm/field/NewsPage/item/542/edit) an uncaught error is thrown:

[Error] Uncaught Error: Call to a member function getTemplateHelper() on string
/var/www/framework/forms/FormField.php:316 

The code seems to try to call a function on a string, rather than on an instance of the form object. Any ideas on what’s going on here?

If any use, here is the full call stack:

* **FormField->getTemplateHelper()**
FormField.php:291
* **FormField->ID()**
FormField.php:574
* **FormField->getAttributes()**
FormAction.php:126
* **FormAction->getAttributes()**
FormField.php:608
* **FormField->getAttributesHTML()**
ViewableData.php:120
* **ViewableData->__get(AttributesHTML)**
ViewableData.php:468
* **ViewableData->obj(AttributesHTML,,,1,AttributesHTML)**
ViewableData.php:742
* **ViewableData_Customised->obj(AttributesHTML,,,1)**
ViewableData.php:539
* **ViewableData->XML_val(AttributesHTML,,1)**
SSViewer.php:187
* **SSViewer_Scope->__call(XML_val,Array)**
SSViewer.php:650
* **SSViewer_DataPresenter->__call(XML_val,Array)**
.cache.framework.templates.forms.FormAction.ss:26
* **include(/var/www/silverstripe-cache/www-data-php7.2.10-0ubuntu0.18.04.1/.cache.framework.templates.forms.FormAction.ss)**
SSViewer.php:1172
* **SSViewer->includeGeneratedTemplate(/var/www/silverstripe-cache/www-data-php7.2.10-0ubuntu0.18.04.1/.cache.framework.templates.forms.FormAction.ss,ViewableData_Customised,,Array,)**
SSViewer.php:1234
* **SSViewer->process(ViewableData_Customised,)**
ViewableData.php:405
* **ViewableData->renderWith(SSViewer)**
FormField.php:855
* **FormField->Field(Array)**
FormAction.php:91
* **FormAction->Field()**
ViewableData.php:466
* **ViewableData->obj(Field,,,1)**
ViewableData.php:539
* **ViewableData->XML_val(Field,,1)**
SSViewer.php:187
* **SSViewer_Scope->__call(XML_val,Array)**
SSViewer.php:650
* **SSViewer_DataPresenter->__call(XML_val,Array)**
.cache.framework.admin.templates.Includes.LeftAndMain_EditForm.ss:184
* **include(/var/www/silverstripe-cache/www-data-php7.2.10-0ubuntu0.18.04.1/.cache.framework.admin.templates.Includes.LeftAndMain_EditForm.ss)**
SSViewer.php:1172
* **SSViewer->includeGeneratedTemplate(/var/www/silverstripe-cache/www-data-php7.2.10-0ubuntu0.18.04.1/.cache.framework.admin.templates.Includes.LeftAndMain_EditForm.ss,Form,,Array,)**
SSViewer.php:1234
* **SSViewer->process(Form,)**
ViewableData.php:405
* **ViewableData->renderWith(SSViewer)**
Form.php:1589
* **Form->forTemplate()**
ViewableData.php:540
* **ViewableData->XML_val(ItemEditForm,,1)**
SSViewer.php:187
* **SSViewer_Scope->__call(XML_val,Array)**
SSViewer.php:650
* **SSViewer_DataPresenter->__call(XML_val,Array)**
.cache.framework.templates.GridFieldDetailForm.ss:2
* **include(/var/www/silverstripe-cache/www-data-php7.2.10-0ubuntu0.18.04.1/.cache.framework.templates.GridFieldDetailForm.ss)**
SSViewer.php:1172
* **SSViewer->includeGeneratedTemplate(/var/www/silverstripe-cache/www-data-php7.2.10-0ubuntu0.18.04.1/.cache.framework.templates.GridFieldDetailForm.ss,ViewableData_Customised,,Array,)**
SSViewer.php:1234
* **SSViewer->process(ViewableData_Customised,)**
ViewableData.php:405
* **ViewableData->renderWith(SSViewer)**
GridFieldDetailForm.php:309
* **GridFieldDetailForm_ItemRequest->edit(SS_HTTPRequest)**
RequestHandler.php:296
* **RequestHandler->handleAction(SS_HTTPRequest,edit)**
RequestHandler.php:208
* **RequestHandler->handleRequest(SS_HTTPRequest,DataModel)**
GridFieldDetailForm.php:102
* **GridFieldDetailForm->handleItem(GridField,SS_HTTPRequest)**
GridField.php:992
* **GridField->handleRequest(SS_HTTPRequest,DataModel)**
RequestHandler.php:230
* **RequestHandler->handleRequest(SS_HTTPRequest,DataModel)**
RequestHandler.php:230
* **RequestHandler->handleRequest(SS_HTTPRequest,DataModel)**
Controller.php:151
* **Controller->handleRequest(SS_HTTPRequest,DataModel)**
LeftAndMain.php:474
* **LeftAndMain->handleRequest(SS_HTTPRequest,DataModel)**
AdminRootController.php:92
* **AdminRootController->handleRequest(SS_HTTPRequest,DataModel)**
Director.php:385
* **Director::handleRequest(SS_HTTPRequest,Session,DataModel)**
Director.php:149
* **Director::direct(/admin/news/NewsPage/EditForm/field/NewsPage/item/542/edit,DataModel)**
main.php:211

Edit: I have also just found out that i am able to edit unpublished articles. The error is only thrown when trying to edit a published news article.


#2

Managed to solve the problem.

Tracked the error down to somewhere in the versioneddataobjects-extension that we also have installed on our site. Updated the extension to a newer version - which solved the problem.