I have a question form where users can answer one out of four answers. I use the custom bootstrap4 radio buttons like so:
What's your favourite number?
<form asp-controller="Test" asp-action="TestPost" method="post"> <div class="form-group"> <div class="custom-control custom-radio custom-control-inline"><input type="radio" id="custom1" name="Question1" class="custom-control-input" />
</div><div class="custom-control custom-radio custom-control-inline"><input type="radio" id="custom10" name="Question1" class="custom-control-input" /></div> <div class="custom-control custom-radio custom-control-inline"><input type="radio" id="custom11" name="Question1" class="custom-control-input" /></div> <div class="custom-control custom-radio custom-control-inline"><input type="radio" id="custom12" name="Question1" class="custom-control-input" /></div> </div><button class="btn btn-primary" type="submit">Next</button>
But it seems like every button is "on" or "off", like a boolean. I want the number corresponding to the radio button to be sent to the controller. Ideally I try to have a property on the viewmodel for each question(not each radio button). So if I have a property like int Question1, then the value would be set depending on what button is ticked. But I can't seem to do it and it's frustrating, hahaha.
Any ideas?
</form>