I'm having problems with Razor ... I need to create a checkbox field and do the binding with my viewModel using pure html. I'm not sure how to do this, but I'm not sure how to do this. (fields are being created dynamically ...)
<div class="checkbox-custom checkbox-default">
<input type="checkbox" name="PessoasContatosViewModel[@i].ContatoPrincipal" class="ckb-contatoPrincipal" autocomplete="off" />
<label asp-for="PessoasContatosViewModel[i].ContatoPrincipal" class="ckb-contatoPrincipal">Contato Principal</label>
</div>
I was able to resolve the problem by validating the checked property, but is it correct?
<div class="col-md-2">
<label class="control-label"> </label>
<div class="checkbox-custom checkbox-default">
<input type="checkbox" name="PessoasContatosViewModel[@i].ContatoPrincipal" value="true" checked ="@(Model.PessoasContatosViewModel[i].ContatoPrincipal)" class="ckb-contatoPrincipal" autocomplete="off" />
<label asp-for="PessoasContatosViewModel[i].ContatoPrincipal" class="ckb-contatoPrincipal">Contato Principal</label>
</div>
</div>