0

When submitting a contact form it redirects to a WSOD and this is logged:

Uncaught PHP Exception InvalidArgumentException: "$string ("Message") must be a string." at /Applications/MAMP/htdocs/onb/core/lib/Drupal/Core/StringTranslation/

I've tried creating new forms and setting them as default. It didn't work. I've also tried uninstalling and installing the contact module without much luck. Any thought on how to fix it or dig up what exactly is causing it?

Thanks.

2 Answers 2

3

You're most likely passing an object or an array to a translation function call. The t() function expects a string as it's first parameter (see the function spec on drupal.org). Search for places where you call the t() function.

More information on how the translation functions are used in D8 can be found on the translation api page on drupal.org. This will give you an idea of how and where you could have translations so you can check those places in your code.

1
  • I found an old template from a previous bootstrap version in my subtheme. I deleted it and things worked fine. Thanks.
    – Jed_BH
    Oct 19, 2018 at 14:35
1

One thing to also watch out is using $this->t or t() function on the method that is accepting string and than translating that string by default. Meaning, we are trying to run the string trough t() function twice.

For example: $route->setDefault('_title', $this->t('some string')). No need to use t() function here because '_title' string is available for translation by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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