{{ define "content" }}

<div class="container">

  {{if .Update}}
  <ol class="breadcrumb">
    <li><a href="/classes">Classi</a></li>
    <li><a href="/classes/{{.Class.ID}}">{{.Class.Name}}</a></li>
    <li class="active"><a href="#">Aggiorna la classe</a></li>
  </ol>  
  {{else}}  
  <ol class="breadcrumb">
    <li><a href="/classes">Classi</a></li>
    <li class="active"><a href="#">Aggiungi</a></li>
  </ol>
  {{end}}

  {{if .Update}}
  <h1 class="karmen-info-header">Aggiorna la classe "{{.Class.Name}}"</h1>
  {{else}}
  <h1 class="karmen-info-header">Crea una nuova classe</h1>
  {{end}}
  
  <form id="form_classes_add_update" action="{{.SubmitUrl}}" method="POST" role="form" data-toggle="validator">
    
    <div class="form-group has-feedback">
      <label class="control-label" for="class_name">Nome</label>
      <input type="text" name="Name" class="form-control" id="class_name" placeholder="Nome" {{if .Update}} value="{{.Class.Name}}" {{end}} required>
    </div>

    <div class="form-group">
      <label class="control-label" for="coordinator_id">Coordinatore</label>
      <select name="coordinator_id" class="form-control selectpicker" id="coordinator_id" placeholder="Coordinatore" data-live-search="true" form="form_classes_add_update" title="Seleziona il nome del coordinatore" data-dropup-auto="false">
	<option value="0"></option>
  	{{range $teacher := .Teachers}}
	{{if $.Update}}
  	<option
	   value="{{$teacher.ID}}"
	   {{index $.SelectedCoordinator $teacher.ID}}>{{$teacher.Name}} {{$teacher.Surname}}
	</option>
	{{else}}
  	<option value="{{$teacher.ID}}">{{$teacher.Name}} {{$teacher.Surname}}</option>
	{{end}}
  	{{end}}
      </select>
    </div>

    
    <div class="form-group">
      <label class="control-label" for="minuter_id">Verbalizzante</label>
      <select name="minuter_id" class="form-control selectpicker" id="minuter_id" placeholder="Verbalizzante" data-live-search="true" form="form_classes_add_update" title="Seleziona il nome del verbalizzante" data-dropup-auto="false">
	<option value="0"></option>
  	{{range $teacher := .Teachers}}
	{{if $.Update}}
  	<option
	   value="{{$teacher.ID}}"
	   {{index $.SelectedMinuter $teacher.ID}}>{{$teacher.Name}} {{$teacher.Surname}}
	</option>
	{{else}}
  	<option value="{{$teacher.ID}}">{{$teacher.Name}} {{$teacher.Surname}}</option>
	{{end}}
  	{{end}}
      </select>
    </div>

    <div class="form-group">
      <button type="submit" class="btn btn-primary">Salva</button>
      {{if .Update}}
      <a href="/classes/{{.Class.ID}}" class="btn btn-default">Annulla</a>
      {{else}}
      <a href="/classes" class="btn btn-default">Annulla</a>
      {{end}}
    </div>
    
  </form>

  
</div>

{{ end }}
