Model:
public class WynajemVm
{
public DateTime Od { get; set; }
public DateTime Do { get; set; }
public string Uwagi { get; set; }
public string ListaKodow { get; set; }
public int MagazynId { get; set; }
}
Widok:
@model Admin.Models.Create.WynajemVm
<link type="text/css" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"/>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Nowy Wynajem</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Od, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input type="text" id="dateOd" name="dateOd"/>
@Html.EditorFor(model => model.Od, "",new {@class = "text-danger"})
@Html.ValidationMessageFor(model => model.Od, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Do, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Do, new { @class = "datetimepicker" })
@Html.ValidationMessageFor(model => model.Do, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Uwagi, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Uwagi, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Uwagi, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.Label("Oddzielając przecinkiem, podaj listę kodów", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ListaKodow, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ListaKodow, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.Label("Wybierz magazyn", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.MagazynId, (IEnumerable<SelectListItem>)ViewBag.magazyny)
@Html.ValidationMessageFor(model => model.ListaKodow, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Dodaj" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Powrót", "Index", null, new { @class = "btn btn-default" })
</div>
<script type="text/javascript">
$(function() {
$('#dateOd').datepicker();
});
</script>
Ten kawałek:
<input type="text" id="dateOd" name="dateOd"/>
dodałem żeby zobaczyć czy na zwykłym input to zadziała - i działa. Natomiast nie działa mi na EditorFor, próbowałem z tym template, ale nie wyszło i usunąłem ten folder