Reviewed & tested by the community
Project:
Conditional Fields
Version:
4.0.0-alpha6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Apr 2025 at 17:35 UTC
Updated:
6 Apr 2026 at 14:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
drupalfan2 commentedPatch
Comment #3
dhruv.mittal commentedComment #5
dhruv.mittal commentedAs patch is deprecated and it is easier to review MR, for that reason I've raised MR from the given patch.
Thanks!
Comment #6
benstallings commentedClaude Code says:
This fixes a crash when $this->form['#attached']['library'] is a string instead of the expected array, which would cause [] (array push) to fail.
It works, but it's papering over a problem upstream — #attached['library'] should always be an array per the Drupal render API. If it's a string, something else set it incorrectly. That said, being defensive here is reasonable since this module processes arbitrary forms it doesn't control.
Minor style nit: The wrapped string value has inconsistent indentation (missing 2 spaces). Should be:
Verdict: Acceptable defensive fix. I'd fix the indentation before merging. Optionally, could also be simplified to just always cast it:
$this->form['#attached']['library'] = (array) ($this->form['#attached']['library'] ?? []);But the current approach is fine with the indent fix.