I do not know how to properly display input in the View.
I make a form for adding managers to the company.
<div class="one field"> <div class="field"> <h3 class="ui dividing header"> Менеджер </h3> </div> </div> foreach (var manager in Model.Supplier.Managers) { <div class="two fields"> <div class="field"> <label>ФИО</label> @Html.TextBoxFor(m => manager.Name) </div> <div class="field"> </div> </div> <div class="two fields"> <div class="field"> <label>Телефон</label> @foreach (var phone in manager.Phones) { @Html.TextBoxFor(m => phone.PhoneNumber) } </div> <div class="field"> <label>Почта</label> @foreach (var email in manager.Emails) { @Html.TextBoxFor(m => email.Contact_Email) } </div> </div> } So, what is logical if I don’t have it in the data model, I’m not drawing this textbox at all. And I need to draw. According to the idea this can be done using IF / but the design will be cumbersome, I would like to know if there is any elegant way to solve this problem?
phoneandemailobject to the collections. This will allow you to always show at least one entry. Other options are to addifto checkiflist is empty, etc. But still, you probably want to add additional addresses and phone numbers, so you will probably have an "Add phone" button, which with JS will draw input fields. - teran