Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dennis 4 posts 74 karma points
    Feb 14, 2023 @ 12:59
    Dennis
    0

    Prefilling form with user information

    Hi,

    I'm brand new to Umbraco and Umbraco forms and have ran into an issue with prefilling my forms with user information.

    Currently all forms are using the same standard FormViewModel and form.cshtml file. We have a service implemented in the solution that allows me to fetch all the information about the user that's currently logged in that i would like to prefill the form with, but i can't see how i can get that information into the form as it is rendered. This would be information like name, email etc.

    I found this Adding A Prevalue Source Type To Umbraco Forms documentation but from my understanding this will only create prevalues that can be selected in backoffice and is not dynamically generated as each form is created?

    Is there any good code examples out there where i could see how a form comes with dynamically prefilled values as the form is rendered if it is possible?

    Thank you in advance, please let me know if anyone would like some more information.

  • Johan Runsten 38 posts 277 karma points c-trib
    May 17, 2023 @ 13:58
    Johan Runsten
    0

    I would also like to know if this is possible.

  • Dennis 4 posts 74 karma points
    Jun 13, 2023 @ 07:25
    Dennis
    0

    Late update if anyone else runs into this post and is interested.

    I solved this by setting some consistent aliases for the fields in Umbraco. Then as the razor view rendered for the next page i read from the form data and updated the prevalue for the fields being rendered with the data. There's probably better solutions to this, but it works.

Please Sign in or register to post replies

Write your reply to:

Draft