useRegisterField
@spartanfx/react / useRegisterField
Function: useRegisterField()
useRegisterField(
listFormContext,fieldInternalName):void
React hook used to register a SharePoint field with the List Form context.
This hook ensures that the specified field is initialized into the form state when the form is ready. It handles both new and existing list items and applies necessary data transformations based on field type.
Supported field types include:
- Multi-lookup
- Multi-choice
- DateTime
- User (people picker)
- All others (used as-is)
Must be called for each field that will be rendered by the form to ensure the correct default or stored value is available.
Parameters
listFormContext
The IListFormContext instance provided by useListFormContext.
fieldInternalName
string
Internal name of the SharePoint field to register.
Returns
void
Throws
Error if the field is not found in the list schema.
Examples
useRegisterField(ctx, 'Title');
useRegisterField(ctx, 'AssignedTo');
useRegisterField(listFormContext, fieldInternalName)
@returns void