Calculator Field Naming
Calculator Field Naming
This note describes the field-naming (function arguement naming) limits and conventions that matter when writing qCalc calculator functions.
Why field names matter
Field names are not just labels. They are used to:
- build DOM ids and input names
- match tab blocks and layout groups
- identify generated child fields such as quantity parts and unit fields
- drive
autofill,related,showhide, andanyofbehavior
That means a field name that looks unique in the Python signature may be treated as a different root name in the UI.
Tokens defined in qconst.py
These constants are part of the current naming contract:
TOK_ID_PREFIX = 'id_'TOK_FIELD_SEP = '_'TOK_UOM = '_uom'TOK_PART = '_part'TOK_PART_UOM = '_part_uom'TOK_ROW = '_row'TOK_COL = '_col'TOK_TABLE_UPDATE = '_table_update'TOK_TABLE_RESIZE = '_table_resize'TOK_TABLE_ED = '_table_ed'TOK_RESULT_SUFFIX = '__r'TOK_LIST_INDEX_PATTERN = r'_\d+$'i.e. names ending with _e.g. _1, _2, _10 etc.
The important takeaway is that several suffixes are already reserved by the framework. Field names that end with one of these fragments can be interpreted as generated internal names.
Practical limitations for authors
- Avoid field names that end in an index-style suffix such as
_1,_2,_10. - Avoid using
_uom,_part, or_part_uomin your own field names. - Avoid
__rat the end of user-facing input names because it is reserved for result naming.
Safe naming guidelines
Good names are semantic and stable:
brand_choicemode_choicecoverage_lowcoverage_midcoverage_high
Avoid names that depend on implicit suffix stripping:
select_1select_2auto_fill_11auto_fill_21
If you want repeated groups, prefer descriptive names over numeric suffixes, or define a separate naming scheme that is consistently handled everywhere.
If you want to change the convention
It is possible to change the convention cleanly, but it is a coordinated refactor, not a single constant edit.
At minimum, review and update:
qconst.pycalc/templatetags/qfilter.pycalc/mod_layout_dynamic.pycalc/templates/layout-render-block.htmlcalc/view_form_data.py- relevant JavaScript helpers under
calc/static/calc/js/ - tests that assert field-root behavior
Rule of thumb
Keep field name free of framework suffix patterns.