- Issue created by @mxh
- 🇫🇷France Grimreaper France 🇫🇷
Hello,
Could you provide the example code to reproduce the bug please?
And try to provide a MR based on what you spotted in the other Bootstrap theme?
- 🇩🇪Germany mxh Offenburg
I have tried to write a test for this, but it seems I cannot reproduce it anymore for now. I also currently don't work on the site anymore where I encountered this problem. I've also tried to reproduce this on a fresh Drupal installation with standard profile, writing a
hook_form_alter
implementation in a module and switch to a theme that is using this theme as base. But still no success.The only thing that I can think of is that maybe the composer autoloading settings are different. But unfortunately I have no more time to spend on trying to reproduce this.
So maybe can be closed as "cannot reproduce" for now?
- 🇫🇷France Grimreaper France 🇫🇷
Ok,
Thanks for your feedback.
Do no hesitate to reopen if needed.
- Status changed to Closed: cannot reproduce
about 1 month ago 10:12pm 9 August 2025 - 🇨🇳China aglobalwander_
Hi
# Response to UI Suite Bootstrap Issue #3540123
## composer.json excerpt
```json
{
"require": {
"drupal/ui_suite_bootstrap": "^5.2@beta",
"drupal/core": "^11.2",
"cweagans/composer-patches": "^1.7"
},
"extra": {
"patches": {
"drupal/ui_suite_bootstrap": {
"Fix autoload issue for class-based hooks": "patches/ui_suite_bootstrap-autoload-fix.patch"
}
}
}
}
```## Environment Details
- **Drupal**: 11.2.2
- **PHP**: 8.3
- **UI Suite Bootstrap**: 5.2.0-beta2
- **Composer version**: 2.x
- **Local environment**: DDEV
- **Has subtheme**: Yes (sas_curriculum)## How I Trigger the Issue
The error occurs consistently in my environment when:
1. Running `drush cr` after any template/CSS changes
2. Sometimes just visiting pages that use form elements
3. After deploying to staging/production## The Patch That Fixed It
I'm attaching the patch file that completely resolves the issue. The patch adds manual class loading since themes don't get PSR-4 autoloading. This has been working stably for our production site.
## Possible Difference
The key difference might be:
- We have a custom subtheme with its own hook implementations
- We're using specific contrib modules that might interact differently
- Our composer autoload configuration might be different## Testing Without the Patch
Without the patch, I get:
```
InvalidArgumentException: Class "Drupal\ui_suite_bootstrap\HookHandler\PreprocessFormElement" does not exist
```With the patch applied, everything works perfectly.
## Note on PHP Attributes
You mentioned that new hooks with PHP Attributes might work better. That could be a good long-term solution, but for now, the manual loading approach is necessary for sites experiencing this issue.
Perhaps it only manifests under specific conditions.
I appreciate all the work done with this project it is great. I thought I wojld share this issue I ran into.