I'm trying to submit a form within a modal, but it's not submitting what I'm sending in the tag.
My VIEW:
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">Novo</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel">Nova Área Responsável</h4>
</div>
<div class="modal-body">
@using (Html.BeginForm("Index", "AreaResponsavel", FormMethod.Post, new { enctype = "multipart/form-data", id = "form" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<div class="form-group">
<label for="recipient-name" class="control-label">Descrição</label>
<input type="text" class="form-control" id="descricao">
</div>
</fieldset>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Salvar</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
}
</div>
</div>
</div>
</div>
My Controller:
public ActionResult Index()
{
var listaDeAreaResponsavel = appAreaResponsavel.ListarTodos();
return View(listaDeAreaResponsavel);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Index(AreaResponsavelDominio areaResponsavel)
{
if (ModelState.IsValid)
{
appAreaResponsavel.Salvar(areaResponsavel);
return RedirectToAction("Index");
}
return View(areaResponsavel);
}
My Model:
public class AreaResponsavelDominio
{
[DisplayName("Código")]
public int CodAreaResponsavel { get; set; }
[DisplayName("Descrição")]
public string Descricao { get; set; }
}
I debugged, and the values being: