[DEFECT] Key-Value fields in Widgets are converted to Strings instead of Maps
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Problem Statement
When rendering a widget, Key-Value fields are being exposed to the Velocity context as plain strings instead of Map objects. This prevents any standard map operations and causes inconsistent behavior compared to regular content types.
Steps to Reproduce
Steps to Reproduce
- Create a Content Type with a Key-Value field (e.g., questionList).
- Create a Widget using this Content Type.
- Add one or more key-value pairs (e.g., a=Value A, b=Value B).
- Place the widget on a page or render it directly.
- In the widget’s Velocity code, print the field and attempt to access keys:
- $questionList
$questionList.a
$questionList.get("a")
$questionList.map.entrySet()
Observe that:
$questionList prints as a raw string: {a=Value A, b=Value B}
All key-based operations return null or errors
Map iteration fails completely
- Workaround : #set($me = $dotcontent.find($ContentInode))
- https://intranet.dotcms.com/support/kb/key-value-fields-in-widgets-issue-and-solution
- https://drive.google.com/file/d/15_VV2e6mRgkmk5xPPAsfHb8hR6C7o8i0/view?usp=sharing
- https://dotcms.freshdesk.com/a/tickets/34071
Acceptance Criteria
Key-Value fields inside widgets should behave like they do in standard content:
Return a proper Map<String, Object>
Support $field.key
Support $field.get("key")
Support iteration via .map.entrySet() or .keys
dotCMS Version
Latest evergreen
Severity
Medium - Some functionality impacted
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the widget rendering path with a Content Type containing a Key-Value field, then inspect how that field is exposed in the Velocity context. Compare it with standard content behavior and the documented $dotcontent.find($ContentInode) workaround. Done means the widget exposes a Map<String, Object> supporting key access, get(), and iteration as listed in the acceptance criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100