simplemap
simplemap copied to clipboard
Object of class ether\simplemap\models\Map could not be converted to string
After updating Craft CMS from 4.2.5.1 to 4.2.5.2 I now get an An internal server error occurred. when browsing the field layout of a page using a Simple Map field. It happens on every page, while the field was working fine previously.
I reverted to 4.2.5.1, but unfortunately the error is still there. Deleting all caches files and run resave/entries does not fix it. Please see error below.
2022-10-10 14:56:17 [web.ERROR] [Error] Object of class ether\simplemap\models\Map could not be converted to string {"trace":["#0 /srv/data/web/vhosts//vendor/craftcms/cms/src/web/twig/Extension.php(1507): yii\\helpers\\BaseHtml::encode()","#1 /srv/data/web/vhosts//storage/runtime/compiled_templates/32/328c81aa9b4a065a9ab43dc91c2939ec.php(65): craft\\web\\twig\\Extension->tagFunction()","#2 /srv/data/web/vhosts//vendor/twig/twig/src/Template.php(394): __TwigTemplate_dfc2b9e2b9ef42f0edf07d01a3d1616f->doDisplay()","#3 /srv/data/web/vhosts//vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#4 /srv/data/web/vhosts//storage/runtime/compiled_templates/1a/1a0ad915466b720fe2c053903103632c.php(558): Twig\\Template->display()","#5 /srv/data/web/vhosts//vendor/twig/twig/src/Extension/CoreExtension.php(1202): __TwigTemplate_d5cfaa5401d11b436971b12d72bbcf86->macro_textarea()","#6 /srv/data/web/vhosts//storage/runtime/compiled_templates/65/65130df0c52daa5c64e4a629655184ac.php(65): twig_call_macro()","#7 /srv/data/web/vhosts//vendor/twig/twig/src/Template.php(394): __TwigTemplate_b9e3d1c8f6dc58eeba424cbba7084eee->doDisplay()","#8 /srv/data/web/vhosts//vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#9 /srv/data/web/vhosts//vendor/twig/twig/src/Template.php(379): Twig\\Template->display()","#10 /srv/data/web/vhosts//vendor/twig/twig/src/TemplateWrapper.php(40): Twig\\Template->render()","#11 /srv/data/web/vhosts//vendor/twig/twig/src/Environment.php(277): Twig\\TemplateWrapper->render()","#12 /srv/data/web/vhosts//vendor/craftcms/cms/src/web/View.php(428): Twig\\Environment->render()","#13 /srv/data/web/vhosts//vendor/craftcms/cms/src/fields/PlainText.php(217): craft\\web\\View->renderTemplate()","#14 /srv/data/web/vhosts//vendor/craftcms/cms/src/base/Field.php(471): craft\\fields\\PlainText->inputHtml()","#15 /srv/data/web/vhosts//vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(269): craft\\base\\Field->getInputHtml()","#16 /srv/data/web/vhosts//vendor/craftcms/cms/src/fieldlayoutelements/BaseField.php(215): craft\\fieldlayoutelements\\CustomField->inputHtml()","#17 /srv/data/web/vhosts//vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(214): craft\\fieldlayoutelements\\BaseField->formHtml()","#18 /srv/data/web/vhosts//vendor/craftcms/cms/src/web/View.php(1558): craft\\fieldlayoutelements\\CustomField->craft\\fieldlayoutelements\\{closure}()","#19 /srv/data/web/vhosts//vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(215): craft\\web\\View->namespaceInputs()","#20 /srv/data/web/vhosts//vendor/craftcms/cms/src/models/FieldLayout.php(738): craft\\fieldlayoutelements\\CustomField->formHtml()","#21 /srv/data/web/vhosts//vendor/craftcms/cms/src/web/View.php(1553): craft\\models\\FieldLayout->craft\\models\\{closure}()","#22 /srv/data/web/vhosts//vendor/craftcms/cms/src/models/FieldLayout.php(737): craft\\web\\View->namespaceInputs()","#23 /srv/data/web/vhosts//vendor/craftcms/cms/src/controllers/ElementsController.php(728): craft\\models\\FieldLayout->createForm()","#24 /srv/data/web/vhosts//vendor/craftcms/cms/src/controllers/ElementsController.php(431): craft\\controllers\\ElementsController->_prepareEditor()","#25 [internal function]: craft\\controllers\\ElementsController->craft\\controllers\\{closure}()","#26 /srv/data/web/vhosts//vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(108): call_user_func()","#27 /srv/data/web/vhosts//vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(48): craft\\web\\CpScreenResponseFormatter->_formatTemplate()","#28 /srv/data/web/vhosts//vendor/yiisoft/yii2/web/Response.php(1095): craft\\web\\CpScreenResponseFormatter->format()","#29 /srv/data/web/vhosts//vendor/craftcms/cms/src/web/Response.php(286): yii\\web\\Response->prepare()","#30 /srv/data/web/vhosts//vendor/yiisoft/yii2/web/Response.php(339): craft\\web\\Response->prepare()","#31 /srv/data/web/vhosts//vendor/yiisoft/yii2/base/Application.php(390): yii\\web\\Response->send()","#32 /srv/data/web/vhosts/htdocs/index.php(12): yii\\base\\Application->run()","#33 {main}"],"memory":29085544,"exception":"[object] (Error(code: 0): Object of class ether\\simplemap\\models\\Map could not be converted to string at /srv/data/web/vhosts//vendor/yiisoft/yii2/helpers/BaseHtml.php:118)"}
Problem solved: I finally found that it was an issue from the project config files, after renaming the field/handle of this field. For a reason I ignore, even if the edits were committed and deployed twice, they were not synced correctly. I had to do a replacement of the whole folder from FTP, then sync the changes, which fixed the error online.
For posterity, we also just ran into this. It turns out that the BaseLocation model can no longer be cast to a string. We had {mapField} in a section title format and switched this to {mapField.address([], ",")} to get this working (address() source).