Copied to clipboard

Flag this post as spam?

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


  • Joshua Lemli 52 posts 234 karma points
    Sep 20, 2017 @ 17:21
    Joshua Lemli
    0

    How to access form data after registration

    I am using a vanilla implementation of the Umbraco registration snippet (which uses UmbRegisterController). I want to include custom input fields in the form, but these values simply need to be passed to the page the form is submitted to. E.g. I have Umbraco Member fields, and also vanilla html fields:

    // Umbraco Member Registration form field:
    @Html.TextBoxFor(m => registerModel.Email)
    // Plain old HTML form field:
    <input type='text' name='someCustomField'>
    

    And I want to be able to access someCustomField on the next/submission page like this:

    if (TempData["FormSuccess"] != null) {
        <span>You entered:</span>
        <span>@Request.Form["someCustomField"]</span>
    }
    

    But the Request object has no Form values. Are these in TempData? How can I get the value for someCustomField ?

  • Nik 1591 posts 7148 karma points MVP 6x c-trib
    Sep 20, 2017 @ 18:09
    Nik
    1

    Hi Joshua,

    As of yet, I've been unable to achieve this myself. One option might be to create a custom workflow and see if you can add the information into temp data from there. However I'm not 100% sure that this will work.

    During the submission process, if the form is successfully submitted the temp data is all cleared out. I believe that Umbraco Forms needs to be updated so that if it is successful it should store the submission reference in Temp Data. It would make out lives much easier.

    Cheers,

    Nik

  • Joshua Lemli 52 posts 234 karma points
    Sep 22, 2017 @ 17:38
    Joshua Lemli
    100

    Creating a custom controller to replace UmbRegisterController allowed me to access Request.Form["attr"].

    @Nik - You were correct, I can then set TempData to pass back form data to the redirect/result page. This looks like:

    CustomRegisterController

    if (Request.Form["attr"] != null) {
        TempData["attr"] = Request.Form["attr"];
    }
    

    ResultView

    if (TempData["attr"]) {
        // use TempData["attr"]
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft