Description
@mieweb/forms-engine currently exports registerFieldComponent(key, component), which only mutates the internal componentMap. This enables the renderer to render custom field types if they exist in a schema, but it does not integrate custom fields into the rest of the system (editor field picker, default props, placeholders, answer extraction grouping, etc.).
We need a complete registration API that registers both:
- The render component
- The field type configuration metadata used by the editor and engine
Problem / Motivation
Without first-class custom field type registration:
- Advanced users cannot extend the editor UI (no picker entry, no label/category)
- Custom fields have no standardized
defaultProps or placeholders when created
- Response extraction cannot reliably classify answers (
answerType missing)
- The current API appears supported but is incomplete in practice
This limits extensibility and encourages internal config modification instead of proper extension.
Proposed Approach
1. Add registerFieldType(key, config) in Engine
Implement registerFieldType() in:
packages/forms-engine/src/helper_shared/fieldTypes-config.js
Responsibilities:
- Register/merge config into
fieldTypes[key]
- Optionally register
componentMap[key] if config.component is provided
- Update
FIELDS_BY_ANSWER_TYPE to include the new key under its answerType
Important:
2. Export from @mieweb/forms-engine
Update:
packages/forms-engine/index.js
Add:
to the public exports.
3. Editor Integration
Ensure custom field types:
- Appear in the editor field picker
- Are grouped by
category
- Display
label
- Use
defaultProps when created
- Respect
placeholder configuration
4. Documentation + Example
Add:
apps/mieweb-forms-docs/docs/advanced/custom-fields.md
Documentation should cover:
- Component structure (
useFieldController, FieldWrapper)
- Edit mode vs preview mode expectations
- Full config options supported by
registerFieldType
answerType usage
- When custom extraction logic is required
- Complete working example
Add example under:
packages/forms-engine/examples/
Include:
CustomRatingField.jsx
register-custom-field.js
README.md
Acceptance Criteria
Notes / Constraints
-
Align defaults with existing built-in field definitions
-
Decide behavior on re-registration:
- Ignore if already exists (current pattern), or
- Allow override with explicit flag
-
Custom answerTypes require extraction logic in the store layer (e.g., buildFieldResponse())
Implementation Checklist
Related Files
packages/forms-engine/src/helper_shared/fieldTypes-config.js
packages/forms-engine/index.js
packages/forms-engine/src/state/formStore.js
packages/forms-editor/...
apps/mieweb-forms-docs/docs/advanced/custom-fields.md
Description
@mieweb/forms-enginecurrently exportsregisterFieldComponent(key, component), which only mutates the internalcomponentMap. This enables the renderer to render custom field types if they exist in a schema, but it does not integrate custom fields into the rest of the system (editor field picker, default props, placeholders, answer extraction grouping, etc.).We need a complete registration API that registers both:
Problem / Motivation
Without first-class custom field type registration:
defaultPropsor placeholders when createdanswerTypemissing)This limits extensibility and encourages internal config modification instead of proper extension.
Proposed Approach
1. Add
registerFieldType(key, config)in EngineImplement
registerFieldType()in:Responsibilities:
fieldTypes[key]componentMap[key]ifconfig.componentis providedFIELDS_BY_ANSWER_TYPEto include the new key under itsanswerTypeImportant:
FIELDS_BY_ANSWER_TYPEis currently derived at module initialization.Runtime registration must either:
Preserve backward compatibility:
registerFieldComponent()must continue to work.2. Export from
@mieweb/forms-engineUpdate:
Add:
registerFieldTypeto the public exports.
3. Editor Integration
Ensure custom field types:
categorylabeldefaultPropswhen createdplaceholderconfiguration4. Documentation + Example
Add:
Documentation should cover:
useFieldController,FieldWrapper)registerFieldTypeanswerTypeusageAdd example under:
Include:
CustomRatingField.jsxregister-custom-field.jsREADME.mdAcceptance Criteria
registerFieldType(key, config)exists in engine and is exportedgetFieldComponent()labelandcategorydefaultProps(must includefieldType: key)FIELDS_BY_ANSWER_TYPEreflects runtime registration without restartanswerTypesanswerTypeextraction requirementsregisterFieldComponent()continues to functionNotes / Constraints
Align defaults with existing built-in field definitions
Decide behavior on re-registration:
Custom
answerTypes require extraction logic in the store layer (e.g.,buildFieldResponse())Implementation Checklist
registerFieldType()infieldTypes-config.jsFIELDS_BY_ANSWER_TYPEpackages/forms-engine/index.jsRelated Files
packages/forms-engine/src/helper_shared/fieldTypes-config.jspackages/forms-engine/index.jspackages/forms-engine/src/state/formStore.jspackages/forms-editor/...apps/mieweb-forms-docs/docs/advanced/custom-fields.md