That solution would work just fine I suppose. Another solution could be to implement an
and implement the
method. This method receives the
element about to be displayed, and would give you a chance to pre-populate the various fields (by traversing the element tree, for which you'd have to write a function so you can find form elements by name. Since all form elements derive from
, they all have a
property, so that should be trivial enough).
However, the problem with that approach is the hardcoded knowledge of the available fields on your form. Far better would be to give each form element knowledge of where to get their value from. In this solution, you would implement your own
that harvests form field elements based on the available field from your external system. You'd essentially iterate over each "external field" definition, and configure the element's descriptor such that their
handler know how to fetch the current user's information for that particular field.
With that in place, you can now design forms by dragging & dropping application-specific form fields (like Name, Phonenumber, City, etc.), and these fields would automatically show the currently authenticated user's details.
Handling the update of the user account's details in the external application could be done as follows:
FormEventHandlerBase and override the
- In that method, get all
FormElement instances using
- Depending on your API into the external system, you now have all the submitted data available to you. Your system probably doesn't support updating individual fields per call, but likely takes some DTO containing all of the updated user information. You
can construct that call and such DTO from this
Validated method and invoke the update.