dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
845 stars 465 forks source link

Underscores Excluded from Content Type Field: Variable Name #28203

Open ian-b-cooper opened 5 months ago

ian-b-cooper commented 5 months ago

Parent Issue

No response

Problem Statement

When creating a content type field, the variable name is automatically generated, however when the field includes an underscore _ it is ignored in the variable name. This is inconsistent with the content type itself, which will respect underscores when the variable name is first created.

This restricts desired naming conventions and makes a particularly larger impact on headless implementations when it is a large part of the implementations taxonomy

Steps to Reproduce

Create a content type with the name _Content_ and see that the variable name that is generated respects the underscores. Then add a field (of any type) and name it _field and observe the underscores removal upon variable name generation.

Acceptance Criteria

Underscores need to be included when the content type field variable name is generated

dotCMS Version

24.x, demo/latest master (potentially earlier versions as well, though currently not tested).

Proposed Objective

Technical User Experience

Proposed Priority

Priority 3 - Average

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

https://dotcms.slack.com/archives/C028Z3R2D/p1712770018507009

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

fabrizzio-dotCMS commented 1 month ago

I can not just force the code to support field names starting with underscore Our docs say our field names are generated following lower camel case https://www.dotcms.com/docs/latest/field-properties#VariableNames have a look at this: https://emn178.github.io/online-tools/convert_lower_camel_case.html?input=_lol I would like to discuss further here. @ian-b-cooper Additionally, anything starting with "underscore" might clash with GraphQL

Here's the method we use to generate our ContentType Names VelocityUtil.convertToVelocityVariable(tryVar, true); while for field name we simply call String var = StringUtils.camelCaseLower(tryVar);

fabrizzio-dotCMS commented 1 month ago

here's PR with some work https://github.com/dotCMS/core/pull/29287/files

dsilvam commented 1 week ago

After testing using the same function we use for generating/suggesting variable names for content types, we decided to leave it as it is currently since it can have not-small implications.