I recently defined a new permission in a custom module in Drupal 8. When trying to access the permissions page to assign roles to the permission I got the following error:
"PHP message: Uncaught PHP Exception InvalidArgumentException: "$string ("") must be a string." at /var/www/html/web/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php line 133"
The error message isn't especially helpful, but it's a really easy fix if you made the same mistake as me.
The issue for me: when defining the permission in mymodule.permission.yml, instead of setting 'title', I'd accidently set 'name', so when Drupal was reading the 'title' for my permission, it was getting an empty string, and fired off the invalid argument exception.
I imagine this is common across other areas of Drupal where you've mislabelled or forgotten a key in a yml file.
- Log in to post comments