-1
I am quite beginner in MVC and was here as a question: In view I have:
<form id="form1" action="/Jogo/ExecutarAcao" method="post">
<input type="radio" id="banana" name="opcao" value="banana" onclick="this.RespostaDoJogador.submit();">
<label for="banana">Banana</label><br>
<input type="radio" id="laranja" name="opcao" value="laranja" onclick="this.RespostaDoJogador.submit();">
<label for="laranja">Laranja</label><br>
<input type="radio" id="melao" name="opcao" value="melao" onclick="this.RespostaDoJogador.submit();">
<label for="melao">Melão</label>
<input type="radio" id="tomate" name="opcao" value="tomate" onclick="this.RespostaDoJogador.submit();">
<label for="tomate">Tomate</label>
<button type="submit" form="form1" value="submit">submit</button>
</form>
And in Controller I have:
[HttpPost]
public IActionResult ExecutarAcao(int idJogo, string playerAction, int player1x, int player1y, int player2x, int player2y, int player3x, int player3y, int player4x, int player4y)
{
Jogo jogoAtual = Repository.CarregarJogo(idJogo);
jogoAtual.ExecutarAcao(playerAction, player1x, player1y, player2x, player2y, player3x, player3y, player4x, player4y);
return View("Prototipo", jogoAtual);
}
And my goal is: The value that is submitted should be the value attributed to the property RespostaDoJogador
, which is a property of Model Game.