Edit User
Edit existing users with validation for usernames, email addresses and optional password changes, and extend the form with application-specific user settings.
Overview
Edit User is a ready-to-use editing Core App. Unlike a generic document editor, it
understands the validation and persistence requirements of its specific document type. It uses
CoreUi\Form\FieldBuilder
to build the form and renders the existing document values on initial load.
The Core App resolves the requested document by ID, displays its editable fields, validates submitted values and updates the document. Invalid submissions return the form with field errors; successful updates return a success view.
Request and rendering flow
- Call
__invoke(ObjectId|string $objectId)with the existing document ID. - The Core App resolves its mapped collection and loads the document.
getFormData()supplies the field definitions and initial values toFieldBuilder.- The
edit()AJAX action receives and validates the submitted data. - On success,
editUserDocument()updates the document; the response renders the success template.
The concrete application must enforce its own access and authorization requirements for editing documents.
Integrating the Core App
Extend CoreApp\Edit\EditUser and map your application collection through getUserCollection().
This keeps the standard editor reusable while allowing the application to supply its own data model
and
validation settings.
| Extension point | Purpose |
|---|---|
getUserCollection() |
Provide the concrete application collection. |
getFormData() |
Customize fields, labels, values and validation feedback. |
editGetFormData() |
Read additional submitted values. |
editValidateFormData() |
Apply additional application-specific validation. |
editUserDocument() |
Apply additional changes to the document during the edit workflow. |
afterEdit() |
Run application-specific logic after successful persistence. |
Real-world integration: appnetos-api-dev
The appnetos-api-dev admin extension adds group assignment and administrator settings, validates group IDs, and applies safeguards when editing the currently signed-in user.
The extension overrides editGetFormData(), editValidateFormData() and
editUserDocument()
to manage group assignments and permissions. afterEdit() is available as a
post-persistence
extension point.
This example demonstrates how the standard editor can be integrated without rebuilding the complete form or AJAX editing workflow.
Templates, localization and customization
The Core App includes versioned Bootstrap templates for the outer editor, form and success response.
The
template paths can be customized through getBaseTemplate(),
getFormTemplate()
and getSuccessTemplate(). The app also includes translation files for localized labels
and
messages.
For a complete explanation of field configuration and rendering, see the separate Core UI
documentation
for CoreUi\Form\FieldBuilder.