0

I am a junior developer and i find it hard to get this form to work. What i am trying to achieve is a multistep form where each view is a form that redirects to the next view containing further more fields for the user to input values into. I Think i got it right how i pass the Model(which is to be modified for every step). I have 4 views and 4 ActionResults. Step1, Step2 etc. So how do i pass both the model and the chosen value from "Choose amount" and the custom amount?

This is what the markup looks like:

<form method="post" id="formStepOne" action="@Url.Action("Step1", "SupporterController", Model)">
<div class="row">
    <div class="large-6 columns">
        <label>Choose amount</label>
        <input type="radio" name="belopp1" value="500" id="value1"><label for="value1">100 dollars</label>
        <input type="radio" name="belopp2" value="350" id="value2"><label for="value2">200 dollars</label>
        <input type="radio" name="belopp3" value="200" id="value3"><label for="value3">400 dollars</label>
    </div>
    <div class="large-4 columns">
        <label>
            Amount(minimum of 400 dollars)
            <input type="text" placeholder="amount" />
        </label>
    </div>
</div>
<div class="large-12 columns">
    <div class="row collapse">
        <div class="small-2 columns">
            <button type="submit" form="formStepOne" value="Submit">Fortsätt</button>
        </div>
    </div>
</div>

And this is what the controllers/actionResults look like

    [HttpPost]
    public ActionResult Step2(SupporterViewModel model)
    {
        //Validate and return
        return PartialView("~/Views/SupporterBlock/SupporterStepThree.cshtml", model);
    }
  • The names of the form element would simply need to correspond to properties on the model. So the custom amount input needs a name, and the names of all four inputs need to be properties on `SupporterViewModel`. – David Nov 07 '16 at 13:22
  • You have to look for Wizard sample, like here http://stackoverflow.com/questions/8923578/create-wizard-steps-in-mvc-and-razor – tym32167 Nov 07 '16 at 13:23
  • Could you show me how you mean with name for custom amount? Thanks for the help but i won't be able to do it the Wizard way tho. :) – Phil_TheAverage Nov 07 '16 at 13:28
  • @Phil_TheAverage: How to add a name? Just add a `name` attribute to the `input` element. Exactly as you *already do* in your other `input` elements. It's sounding like what you're looking for are introductory tutorials to ASP.NET, HTML, etc. – David Nov 07 '16 at 13:41

0 Answers0