Привязка составных моделей

Версия 2.2 от Alexandr Fokin на 2021/05/14 16:26

Привязка элемента массива из модели.
Необходимо явно указать привязку через параметр htmlFieldName в виде:
ArrayProperty[Index].ItemProperty

  @Html.EditorFor(
    modelItem => exercise.id,
    templateName: null,
    htmlFieldName: $"{nameof(Model.CurrentSelectedExerciseEntity)}[{i}].{nameof(exercise.id)}",
    additionalViewData: new { htmlAttributes = new { @class = "form-control" } }
  )