{{ define "content" }}

<div class="container">

  {{$update := .Options.Get "update"}}

  {{if $update}}
  {{template "breadcrumb" toSlice "Dipartimenti" (all "Department") (.Data|string) (.Data.ID|show "Department") "Aggiorna" "current"}}
  {{else}}
  {{template "breadcrumb" toSlice "Dipartimenti" (all "Department") "Aggiungi" "current"}}
  {{end}}
  
  {{template "add_update_header" dict "update" $update "addTitle" "Crea nuovo dipartimento" "updateTitle" (printf "Aggiorna dipartimento %s" (.Data|string))}}

  {{$form := "form_departments_add_update"}}
  <form
    class="needs-validation"
    action="{{if $update}}{{.Data.ID|update "Department"}}{{else}}{{create "Department"}}{{end}}"
    method="POST"
    role="form"
    id={{$form}}>

    {{$options := ` { name: "Name",id: "department_name",label: "Nome",placeholder: "Nome",type: "text",required: "true"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "Name") "update" $update}}

    {{$options := ` { name: "coordinator_id", id: "coordinator_id", label: "Coordinatore", title: "Seleziona il coordinatore"}`}}
    {{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllTeachers") "selected" (.Data|field "SelectedCoordinator") "update" $update "form" $form}}
    
    {{ $options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Department"} ` }}
    {{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
  
  </form>
  
</div>

{{ end }}
